Created
June 20, 2018 13:35
-
-
Save tombooth/f4e27810a6d2d1d2ca747666c39a3789 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
require 'json' | |
Terrafying::Generator.generate do | |
resource :aws_iam_role, "test_assume_role", { | |
name: "test-assume-role", | |
assume_role_policy: JSON.pretty_generate( | |
{ | |
Version: "2012-10-17", | |
Statement: [ | |
{ | |
Sid: "", | |
Action: "sts:AssumeRole", | |
Effect: "Allow", | |
Principal: { | |
AWS: "arn:aws:iam::#{aws.account_id}:role/kiam_role", | |
}, | |
Condition: { | |
StringLike: { | |
"aws:userid": "${aws_iam_role.kiam_role.unique_id}:cluster.namespace.service-account-name", | |
}, | |
}, | |
}, | |
], | |
} | |
), | |
} | |
role = resource :aws_iam_role, "kiam_role", { | |
name: "kiam_role", | |
assume_role_policy: JSON.pretty_generate( | |
{ | |
Version: "2012-10-17", | |
Statement: [ | |
{ | |
Action: "sts:AssumeRole", | |
Principal: { | |
AWS: "arn:aws:iam::#{aws.account_id}", | |
}, | |
Effect: "Allow", | |
Sid: "" | |
}, | |
], | |
} | |
), | |
} | |
resource :aws_iam_role_policy, "kiam_role_policy", { | |
name: "kiam_role_assume", | |
role: role, | |
policy: JSON.pretty_generate( | |
{ | |
Version: "2012-10-17", | |
Statement: [ | |
{ | |
Action: [ | |
"sts:AssumeRole" | |
], | |
Effect: "Allow", | |
Resource: "arn:aws:iam::#{aws.account_id}:role/test-assume-role", | |
}, | |
], | |
} | |
), | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment