From edce09087f3371d25426af7f7a130c87d0f690d1 Mon Sep 17 00:00:00 2001 From: Kamil Hristov Date: Mon, 22 Nov 2021 21:28:28 +0200 Subject: [PATCH] fix: allow example to be applied without changes Get account_id from aws_caller_identity --- examples/complete/README.md | 1 + examples/complete/main.tf | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/complete/README.md b/examples/complete/README.md index dd88389..23ccf63 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -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 diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 8c02b5f..afb39ff 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -2,6 +2,8 @@ provider "aws" { region = "eu-west-1" } +data "aws_caller_identity" "current" {} + resource "aws_kms_key" "this" {} module "users_unencrypted" { @@ -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",