-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from terraform-modules/tfstate-policy
add iam policy
- Loading branch information
Showing
5 changed files
with
74 additions
and
23 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 |
|---|---|---|
|
|
@@ -4,3 +4,6 @@ | |
| - initial creation | ||
| - module: terraform-state | ||
|
|
||
|
|
||
| * v1.1 -- 20210223 | ||
| - add iam policy to terraform-state | ||
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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| locals { | ||
| _module_version = "1.0" | ||
| _module_version = "1.1" | ||
| } |
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
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
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,59 @@ | ||
| data "aws_iam_policy_document" "tfstate" { | ||
| statement { | ||
| sid = "TFRemoteStateList" | ||
| effect = "Allow" | ||
| resources = [aws_s3_bucket.tfstate.arn] | ||
| actions = ["s3:ListBucket"] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "TFRemoteState" | ||
| effect = "Allow" | ||
| resources = ["${aws_s3_bucket.tfstate.arn}/*"] | ||
| actions = ["s3:GetObject", "s3:PutObject"] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "TFRemoteStateDDB" | ||
| effect = "Allow" | ||
| resources = [aws_dynamodb_table.tfstate.arn] | ||
| actions = ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:DeleteItem"] | ||
| } | ||
| } | ||
|
|
||
| #--- | ||
| # access policy for tfstate key | ||
| #--- | ||
| data "aws_iam_policy_document" "tfstate_kms" { | ||
| policy_id = "inf_kms_access" | ||
| statement { | ||
| sid = "TFStateKMSManagement" | ||
| effect = "Allow" | ||
| actions = ["kms:*"] | ||
| resources = ["*"] | ||
| principals { | ||
| type = "AWS" | ||
| identifiers = [ | ||
| # aws_iam_role.inf-cloud-admin.arn, | ||
| format("arn:%v::iam::%v:root", data.aws_arn.current.partition, local.account_id), | ||
| ] | ||
| } | ||
| } | ||
| ## figure out the right settings, needs to be on the tfstate policy not the key | ||
| ## statement { | ||
| ## sid = "TFStateKMSUse" | ||
| ## effect = "Allow" | ||
| ## actions = [ | ||
| ## "kms:Encrypt", | ||
| ## "kms:Decrypt", | ||
| ## "kms:ReEncrypt*", | ||
| ## "kms:GenerateDataKey*", | ||
| ## "kms:DescribeKey", | ||
| ## ] | ||
| ## resources = ["*"] | ||
| ## principals { | ||
| ## type = "Service" | ||
| ## identifiers = ["delivery.logs.amazonaws.com"] | ||
| ## } | ||
| ## } | ||
| } |