Skip to content

Instantly share code, notes, and snippets.

@ashishmohite
Last active October 18, 2020 08:48
Show Gist options
  • Select an option

  • Save ashishmohite/4e8ffe0186d489b9da6749b1053c6dcf to your computer and use it in GitHub Desktop.

Select an option

Save ashishmohite/4e8ffe0186d489b9da6749b1053c6dcf to your computer and use it in GitHub Desktop.
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
variable "dest_account_id" {
description = "id of destination AWS account"
type = string
}
data "aws_iam_policy_document" "trust_relationship_document" {
statement {
sid = "1"
actions = [
"sts:AssumeRole"
]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
effect = "Allow"
}
}
data "aws_iam_policy_document" "policy_document" {
statement {
sid = "1"
actions = [
"sts:AssumeRole"
]
resources = [
"arn:aws:iam::${var.dest_account_id}:role/assume-lambda-role”
]
effect = "Allow"
}
}
resource "aws_iam_role" "lambda_execution_role" {
name = "lambda-execution-role"
assume_role_policy = data.aws_iam_policy_document.trust_relationship_document.json
}
resource "aws_iam_role_policy" "policy" {
policy = data.aws_iam_policy_document.policy_document.json
role = aws_iam_role.assume_lambda_role.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment