Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an IAM policy example to the README #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .config/.terraform-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ content: |-
{{ include "examples/no_trusted_accounts.tfnot" }}
```

### Example - Minimum IAM Policy
The following policy represents one containing the fewest actions required to
apply the module with only required inputs defined. Additional actions may be
required in order to update or delete this module's resources or if certain
optional inputs are also defined.

```json
{{ include "examples/minimum_iam_policy.json" }}
```

---

{{ .Resources }}
Expand Down
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,99 @@ output "terraform_state_kms_key_arn" {
}
```

### Example - Minimum IAM Policy
The following policy represents one containing the fewest actions required to
apply the module with only required inputs defined. Additional actions may be
required in order to update or delete this module's resources or if certain
optional inputs are also defined.

```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateKMSKeyStatement1",
"Effect": "Allow",
"Action": ["kms:CreateKey", "kms:ListAliases"],
"Resource": ["*"]
},
{
"Sid": "CreateKMSKeyStatement2",
"Effect": "Allow",
"Action": [
"kms:DescribeKey",
"kms:EnableKeyRotation",
"kms:GetKeyPolicy",
"kms:GetKeyRotationStatus",
"kms:ListResourceTags",
"kms:TagResource"
],
"Resource": ["arn:aws:kms:*:111111111111:key/*"]
},
{
"Sid": "CreateKMSKeyStatement3",
"Effect": "Allow",
"Action": ["kms:CreateAlias"],
"Resource": [
"arn:aws:kms:*:111111111111:alias/example-remote-state-backend-default-key",
"arn:aws:kms:*:111111111111:key/*"
]
},
{
"Sid": "CreateTfStateLockTableStatement1",
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
"dynamodb:DescribeContinuousBackups",
"dynamodb:DescribeTable",
"dynamodb:DescribeTimeToLive",
"dynamodb:ListTagsOfResource",
"dynamodb:TagResource",
"dynamodb:UpdateContinuousBackups"
],
"Resource": [
"arn:aws:dynamodb:*:111111111111:table/example-remote-state-backend"
]
},
{
"Sid": "CreateTfStateLockTableStatement2",
"Effect": "Allow",
"Action": ["kms:CreateGrant"],
"Resource": ["arn:aws:kms:*:111111111111:key/*"]
},
{
"Sid": "CreateTfStateBucketStatement",
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:GetAccelerateConfiguration",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetBucketLogging",
"s3:GetBucketObjectLockConfiguration",
"s3:GetBucketPolicy",
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketRequestPayment",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetBucketWebsite",
"s3:GetEncryptionConfiguration",
"s3:GetLifecycleConfiguration",
"s3:GetReplicationConfiguration",
"s3:ListBucket",
"s3:PutBucketLogging",
"s3:PutBucketPolicy",
"s3:PutBucketPublicAccessBlock",
"s3:PutBucketTagging",
"s3:PutBucketVersioning",
"s3:PutEncryptionConfiguration"
],
"Resource": ["arn:aws:s3:::example-remote-state-backend"]
}
]
}
```

---

## Resources
Expand Down
84 changes: 84 additions & 0 deletions examples/minimum_iam_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateKMSKeyStatement1",
"Effect": "Allow",
"Action": ["kms:CreateKey", "kms:ListAliases"],
"Resource": ["*"]
},
{
"Sid": "CreateKMSKeyStatement2",
"Effect": "Allow",
"Action": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "kms:Decrypt",
Needed for re-init terraform using the remote values

"kms:DescribeKey",
"kms:EnableKeyRotation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "kms:GenerateDataKey",
Needed for moving the state form local to s3

"kms:GetKeyPolicy",
"kms:GetKeyRotationStatus",
"kms:ListResourceTags",
"kms:TagResource"
],
"Resource": ["arn:aws:kms:*:111111111111:key/*"]
},
{
"Sid": "CreateKMSKeyStatement3",
"Effect": "Allow",
"Action": ["kms:CreateAlias"],
"Resource": [
"arn:aws:kms:*:111111111111:alias/example-remote-state-backend-default-key",
"arn:aws:kms:*:111111111111:key/*"
]
},
{
"Sid": "CreateTfStateLockTableStatement1",
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "dynamodb:DeleteItem",
to work with the remote state

"dynamodb:DescribeContinuousBackups",
"dynamodb:DescribeTable",
"dynamodb:DescribeTimeToLive",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "dynamodb:GetItem",
Needed for re-init terraform using the remote values

"dynamodb:ListTagsOfResource",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "dynamodb:PutItem",

Needed for re-init terraform using remote values

"dynamodb:TagResource",
"dynamodb:UpdateContinuousBackups"
],
"Resource": [
"arn:aws:dynamodb:*:111111111111:table/example-remote-state-backend"
]
},
{
"Sid": "CreateTfStateLockTableStatement2",
"Effect": "Allow",
"Action": ["kms:CreateGrant"],
"Resource": ["arn:aws:kms:*:111111111111:key/*"]
},
{
"Sid": "CreateTfStateBucketStatement",
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:GetAccelerateConfiguration",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetBucketLogging",
"s3:GetBucketObjectLockConfiguration",
"s3:GetBucketPolicy",
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketRequestPayment",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetBucketWebsite",
"s3:GetEncryptionConfiguration",
"s3:GetLifecycleConfiguration",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add
"s3:GetObject",
"s3:GetObjectVersion",
Needed for moving the state form local to s3

"s3:GetReplicationConfiguration",
"s3:ListBucket",
"s3:PutBucketLogging",
"s3:PutBucketPolicy",
"s3:PutBucketPublicAccessBlock",
"s3:PutBucketTagging",
"s3:PutBucketVersioning",
"s3:PutEncryptionConfiguration"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "s3:PutLifecycleConfiguration"
needed for logging bucket

and "s3:PutObject"
Needed for moving the state form local to s3

],
"Resource": ["arn:aws:s3:::example-remote-state-backend"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add in resource the logging bucket
example-logging

Add the state object that will be move from local to s3
"arn:aws:s3:::example-remote-state-backend/eample-account.tfstate"

}
]
}