Skip to content

Commit

Permalink
fix: allow example to be applied without changes
Browse files Browse the repository at this point in the history
Get account_id from aws_caller_identity
  • Loading branch information
kamilhristov committed Nov 22, 2021
1 parent 5c3cf3c commit edce090
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Note that this example may create resources which cost money. Run `terraform des
|------|------|
| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
| [aws_sqs_queue_policy.users_unencrypted_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |

## Inputs

Expand Down
4 changes: 3 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ provider "aws" {
region = "eu-west-1"
}

data "aws_caller_identity" "current" {}

resource "aws_kms_key" "this" {}

module "users_unencrypted" {
Expand Down Expand Up @@ -37,7 +39,7 @@ resource "aws_sqs_queue_policy" "users_unencrypted_policy" {
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::myaccount:root"
"AWS": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
},
"Action": [
"SQS:SendMessage",
Expand Down

0 comments on commit edce090

Please sign in to comment.