Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removed hardcoded AWS account and added data resource to lookup curre…
…nt aws account
  • Loading branch information
msharma24 committed Mar 4, 2022
commit 9d0754f5b4e2d2a0827015aa38d9fed2b8d58e6b
10 changes: 6 additions & 4 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ provider "aws" {
skip_requesting_account_id = true
}

data "aws_caller_identity" "current" {}

####################################################
# Lambda Function (building locally, storing on S3,
# set allowed triggers, set policies)
Expand Down Expand Up @@ -51,15 +53,15 @@ module "lambda_function" {
allowed_triggers = {
APIGatewayAny = {
service = "apigateway"
source_arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0/*/*/*"
source_arn = "arn:aws:execute-api:eu-west-1:${data.aws_caller_identity.current.account_id}:aqnku8akd0/*/*/*"
},
APIGatewayDevPost = {
service = "apigateway"
source_arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0/dev/POST/*"
source_arn = "arn:aws:execute-api:eu-west-1:${data.aws_caller_identity.current.account_id}:aqnku8akd0/dev/POST/*"
},
OneRule = {
principal = "events.amazonaws.com"
source_arn = "arn:aws:events:eu-west-1:135367859851:rule/RunDaily"
source_arn = "arn:aws:events:eu-west-1:${data.aws_caller_identity.current.account_id}:rule/RunDaily"
}
}

Expand All @@ -74,7 +76,7 @@ module "lambda_function" {
principals = {
account_principal = {
type = "AWS",
identifiers = ["arn:aws:iam::135367859851:root"]
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
}
condition = {
Expand Down