Search code examples
amazon-web-servicesaws-cloudformationaws-code-deployaws-codepipelineaws-codecommit

Create Resource in Bulk from Single CloudFormation Template with CodePipeline


I have to create multiple IAM users from a single cloudformation stack at once.

Since, Cloudformation doesn't support Loop. I have Created a Code Pipeline which deploys cloudformation template stored in AWS CodeCommit.

Can I use Parameter Override Feature of Code Pipeline to Create Multiple Users like giving parameter in list as:

{
   "Username":["Bob","Alice","John"]
}

Solution

  • You're going to need an action between the CodeCommit and CloudFormation actions to generate a template that includes each IAM user resource (unless you plan to commit the expanded CloudFormation template). CodeBuild is probably your best bet to run some command that generates the CoudFormation template.

    You might find CDK (https://github.com/awslabs/aws-cdk/) interesting for a use case like this. It will let you describe IAM users in a loop and then synthesize a CoudFormation temple. At the time of writing this answer it's in preview, so don't rely on it for production.