-
-
Save 9oelM/9ba78bb7025951e4166a923381436172 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
resource "aws_iam_role" "hello" { | |
name = "hello_role" | |
assume_role_policy = jsonencode({ | |
"Version" : "2012-10-17", | |
"Statement" : [ | |
{ | |
"Effect" : "Allow", | |
"Principal" : { | |
# this should be set as the 'default' user on your AWS cli. | |
# get 'localtf' user's ARN from AWS IAM console | |
# it should look like: arn:aws:iam::{aws-account-id}:user/localtf | |
# example: arn:aws:iam::123456789:user/localtf | |
"AWS" : "arn:aws:iam::123456789:user/localtf" | |
"Service" : [ | |
"lambda.amazonaws.com" | |
] | |
}, | |
"Action" : "sts:AssumeRole" | |
} | |
] | |
}) | |
} | |
resource "aws_iam_policy" "hello" { | |
name = "hello_policy" | |
description = "policy needed to run hello server stack" | |
policy = jsonencode({ | |
"Version" : "2012-10-17", | |
"Statement" : [ | |
{ | |
"Action" : [ | |
"lambda:*", | |
"iam:*", | |
"ecr:*", | |
"cloudformation:*", | |
"apigateway:*", | |
"logs:*", | |
"route53:*", | |
"acm:*", | |
"cloudfront:*", | |
"ec2:*" | |
], | |
"Effect" : "Allow", | |
"Resource" : "*" | |
} | |
] | |
}) | |
} | |
resource "aws_iam_role_policy_attachment" "hello" { | |
role = aws_iam_role.hello.name | |
policy_arn = aws_iam_policy.hello.arn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment