johnhamelink
9/10/2015 - 4:55 PM

lambda.tf

resource "aws_iam_role" "snsToSlack" {
  name = "snsToSlack"
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {"Condition":
      {"ArnLike":{"AWS:SourceArn":"${aws_sns_topic.production_api_app_launch.arn}"}},
      "Resource":"${aws_lambda_function.snsToSlack.arn}",
      "Action":"lambda:invokeFunction",
      "Principal":{"Service":"sns.amazonaws.com"},
      "Sid":"sns invoke","Effect":"Allow"
    }
  ]
}
EOF
}