0

I have a CloudFormation template which creates a simple CodeCommit repository and places some code in it, based on a ZIP file in S3. However, the code inside this ZIP file has been parameterized using Cookiecutter. Right now the CloudFormation template just pushes the code to the repository, but is there any way to push the parameterized code to the repository, i.e. by defining the values of the parameters? This would require running the cookiecutter command through the CloudFormation template.

vdvaxel
  • 667
  • 1
  • 14
  • 41
  • Could this help maybe: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html? – Marko E Sep 15 '21 at 08:24
  • Not sure how I would use this? I’m quite new to AWS in general, I have mostly experience in Azure. Basically I would need to run a CodeBuild which I have already created, but I can’t seem to find a way to do it via a CloudFormation template. The only examples I find create a CodeBuild but I already have one created and would like to reuse it multiple times, just with different parameters. – vdvaxel Sep 15 '21 at 11:17

1 Answers1

0

This would require running the cookiecutter command through the CloudFormation template.

Well, you either can create a small script that does that and updates your file in S3, or create a proper CI/CD pipeline with CodeBuild action. The action would run your cookiecutter to setup your code for publication in S3. There is also AWS CloudFormation action which could fallow the CodeBuild action to deploy your template with the parameterized code.

There are also other options, one already mentioned in the comments using custom resources.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Hi Marcin, I have indeed already built a CodeBuild action to run the Cookiecutter command and it works perfectly. However, the part I struggle with is the integration with Sagemaker. I would like to have the newly created repository show up as a "project" in Sagemaker as if you would use the user interface of Sagemaker to create a new project (Sagemaker components & registries > Create new project). Any idea on how this could be achieved? It seems I need to create a custom "organization template" and this can only be done through CloudFormation. – vdvaxel Sep 15 '21 at 09:09
  • To put it differently: is it possible to just run an existing CodeBuild from a CloudFormation template? I can only find examples where a CodeBuild is created from the CloudFormation template, but in my case the CodeBuild is already there, so I just need to run it with the right parameters. – vdvaxel Sep 15 '21 at 10:48
  • @vdvaxel `is it possible to just run an existing CodeBuild from a CloudFormation template?` - yes you can, but this requires a custom resource in CloudFormation. – Marcin Sep 16 '21 at 00:25
  • @vdvaxel How did it go? Still unclear what you can do? – Marcin Oct 03 '21 at 00:04