Skip to content

Instantly share code, notes, and snippets.

@DanielDaCosta
Created June 20, 2020 17:17
Show Gist options
  • Select an option

  • Save DanielDaCosta/e514e33c2a6592232888c9693f83ebcf to your computer and use it in GitHub Desktop.

Select an option

Save DanielDaCosta/e514e33c2a6592232888c9693f83ebcf to your computer and use it in GitHub Desktop.
resource "aws_iam_role" "apiSQS" {
name = "apigateway_sqs"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
data "template_file" "gateway_policy" {
template = file("policies/api-gateway-permission.json")
vars = {
sqs_arn = aws_sqs_queue.queue.arn
}
}
resource "aws_iam_policy" "api_policy" {
name = "api-sqs-cloudwatch-policy"
policy = data.template_file.gateway_policy.rendered
}
resource "aws_iam_role_policy_attachment" "api_exec_role" {
role = aws_iam_role.apiSQS.name
policy_arn = aws_iam_policy.api_policy.arn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment