-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOPS-101 Add s3 policy to role for jenkins
- Loading branch information
Showing
2 changed files
with
358 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
We use jenkins to automate deployment with Terraform. Jenkins | ||
is set up in a different AWS account. | ||
This group of IAM resources allow jenkins to assume a role needed | ||
to deploy resources (and make changes to backend). | ||
*/ | ||
|
||
data "aws_iam_policy_document" "terraform_backend_account_policy" { | ||
statement { | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::191447213457:role/jenkins-role"] | ||
} | ||
|
||
actions = ["sts:AssumeRole"] | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "terraform_backend_role" { | ||
name = "terraform_backend_admin" | ||
assume_role_policy = data.aws_iam_policy_document.terraform_backend_account_policy.json | ||
} | ||
|
||
data "aws_iam_policy_document" "terraform_backend_role_policy_document" { | ||
statement { | ||
effect = "Allow" | ||
|
||
actions = ["s3:*"] | ||
resources = ["arn:aws:s3:::${module.bootstrap.state_bucket}/*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "terraform_backend_role_policy" { | ||
name = "terraform-backend-role-policy" | ||
policy = data.aws_iam_policy_document.terraform_backend_role_policy_document.json | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "terraform_backend_attachment" { | ||
role = aws_iam_role.terraform_backend_role.name | ||
policy_arn = aws_iam_policy.terraform_backend_role_policy.arn | ||
} |
Oops, something went wrong.