Make use of "AWS::IAM::AccessKey" resource type to get credentials and use throughout anywhere in the cloudformation script.
Depends on
AWS::IAM::User : for its userName value.
Syntax
eg.
"HostKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : { "Ref": "User" }
}
},
How to get UserName ? Ref: "User" ?
Use AWS::IAM::User
eg.
"User" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Path": "/",
"Policies": [{
"PolicyName": "root",
"PolicyDocument": { "Statement":[{
"Effect":"Allow",
"Action":"*",
"Resource":"*"
}
]}
}]
}
}
To get various string values do this:
Extra: To get user logged in aws region: { "Ref" :"AWS::Region" }
Reference:
Depends on
AWS::IAM::User : for its userName value.
Syntax
{ "Type": "AWS::IAM::AccessKey", "Properties": { "Serial": Integer, "Status": String, "UserName": String } }
eg.
"HostKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : { "Ref": "User" }
}
},
How to get UserName ? Ref: "User" ?
Use AWS::IAM::User
eg.
"User" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Path": "/",
"Policies": [{
"PolicyName": "root",
"PolicyDocument": { "Statement":[{
"Effect":"Allow",
"Action":"*",
"Resource":"*"
}
]}
}]
}
}
To get various string values do this:
- access-key: {"Ref" : "HostKeys" }
- secret-key: { "Fn::GetAtt" : [ "HostKeys", "SecretAccessKey" ]}
Extra: To get user logged in aws region: { "Ref" :"AWS::Region" }
Reference:
- http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html
- http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-iam.html#scenario-iam-accesskey
Very informative, thanks for providing useful information keep update with more information. Get touch with AWS Online Course Bangalore
ReplyDelete