Last active
October 18, 2020 08:49
-
-
Save ashishmohite/000d67eb39f0e1ef9759ca4a65c02af9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_caller_identity" "current" {} | |
data "aws_region" "current" {} | |
variable "source_account_id" { | |
description = "id of source AWS account" | |
type = string | |
} | |
data "aws_iam_policy_document" "trust_relationship_document" { | |
statement { | |
sid = "1" | |
actions = [ | |
"sts:AssumeRole" | |
] | |
principals { | |
type = "AWS" | |
identifiers = ["arn:aws:iam::${var.source_account_id}:role/lambda-execution-role"] | |
} | |
effect = "Allow" | |
} | |
} | |
data "aws_iam_policy_document" "policy_document" { | |
statement { | |
sid = "1" | |
actions = [ | |
"kinesis:DescribeStream", | |
"kinesis:ListStreams", | |
"kinesis:PutRecord", | |
"kinesis:PutRecords" | |
] | |
resources = [ | |
"arn:aws:kinesis:us-east-1:${data.aws_region.current.name}:stream/destination-stream" | |
] | |
effect = "Allow" | |
} | |
} | |
resource "aws_iam_role" "assume_lambda_role" { | |
name = "assume-lambda-role" | |
assume_role_policy = data.aws_iam_policy_document.trust_relationship_document.json | |
} | |
resource "aws_iam_role_policy" "assume_lambda_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