Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ### New role creation
  2. ### Here assume_role_policy MUST be defined for the trust relationship
  3.  
  4. resource "aws_iam_role" "codedeploy_service_role" {
  5. name = "CodeDeployServiceRole"
  6. assume_role_policy = <<EOF
  7. {
  8. "Version": "2012-10-17",
  9. "Statement": [
  10. {
  11. "Action": "sts:AssumeRole",
  12. "Principal": {
  13. "Service": "ec2.amazonaws.com"
  14. },
  15. "Effect": "Allow",
  16. "Sid": ""
  17. }
  18. ]
  19. }
  20. EOF
  21. }
  22.  
  23. ### AWS policy ARN for existing service role
  24.  
  25. data "aws_iam_policy" "codedeploy_service_policy" {
  26. arn = "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole"
  27. }
  28.  
  29.  
  30. ### Policy attachment
  31.  
  32. resource "aws_iam_role_policy_attachment" "codedeploy_service_role_policy_attach" {
  33. role = "${aws_iam_role.codedeploy_service_role.name}"
  34. policy_arn = "${data.aws_iam_policy.codedeploy_service_policy.arn}"
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement