Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created May 1, 2023 01:06
Show Gist options
  • Select an option

  • Save KyMidd/c909ee8a5190ad30c51a9c7aced3879a to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/c909ee8a5190ad30c51a9c7aced3879a to your computer and use it in GitHub Desktop.
# Build data source to find AWS account id
data "aws_caller_identity" "current" {}
# Get region
data "aws_region" "current" {}
resource "aws_iam_role_policy" "GitHubCopRepoTrigger_Cloudwatch" {
name = "Cloudwatch"
role = aws_iam_role.GitHubCopNewRepoTriggerRole.id
policy = jsonencode(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "logs:CreateLogGroup",
"Resource" : "arn:aws:logs:us-east-1:${data.aws_caller_identity.current.id}:*"
},
{
"Effect" : "Allow",
"Action" : [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource" : [
"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:log-group:/aws/lambda/GitHubCopRepoTrigger:*"
]
}
]
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment