2

how can we set/assign name of any IAM role while creating an IAM role with cloudformation. Say i want to create an IAM role with name NewRole, using cloudformation script, but i cant find any parameter in resource declaration for IAM role, where we can define name of the IAM role to be created.

Hardeep Singh
  • 374
  • 4
  • 11

2 Answers2

4

Simply provide the RoleName (AWS docs) attribute on your role declaration.

yaml:

RoleLogicalId: Type: "AWS::IAM::Role" Properties: RoleName: String [...]

Note that the documentation contains warnings and notes the consequences of using this attribute.

p.s. @dsmsk80 was correct but this was changed.

Erik Erikson
  • 156
  • 2
1

IAM role name is not possible to set from CloudFormation template. But you know how it is formatted when the stack and related role resource is created:

CFStackName-CFIAMRoleResourceName-RandomString

CloudFormation AWS::IAM::Role resource documentation

dsmsk80
  • 5,757
  • 17
  • 22