Khon Lieu
Khon Lieu

Reputation: 4365

How does AWS Amplify cloudformation parameter.json work?

I recently started using AWS Amplify and I've had experience using vanilla cloudformation. Most of it makes sense except for the parameters.json part.

It seems that Amplify generates cloudformation templates for the resources we use, but it also generates a parameters.json file, which I thought was the equivalent of the Parameters section of cloudformation, but it doesn't seem to be.

In Amplify parameters.json the content is just on object with key-value pairs. Whereas in cloudformation, parameters has a defined syntax as noted in the docs.

Also in parameters.json it seems to be able to make a Ref call in the same manner as cloudformation templates. Does anyone know what is parsing the parameters.json file and replacing Ref with actual value?

For example in the storage category, the parameters.json file has key like this

"authRoleName": {
    "Ref": "AuthRoleName"
},

AuthRoleName seems to be defined in both amplify-meta.json under the backend directory, but it's also defined in team-provider-info.json under the amplify directory.

Does anyone know which AuthRoleName file it's using? From what I read in the docs, both amplify-meta.json and team-provider-info.json is auto generated.

A lot of these questions came up because I was curious if I could execute the autogenerated CF templates in CF manually in cloudformation UI. When I tried and copied the Parameters section in and the Metadata section in, I got invalid syntax.

This led me to think amplify is using it's own parser to generate a finalized CF template and executing it in CF. I tried searching through the cli repo, but couldn't find it.

Upvotes: 18

Views: 3651

Answers (1)

Samih3
Samih3

Reputation: 184

A bit late but might still be useful. You have a couple of questions here:

Does anyone know which AuthRoleName file it's using? From what I read in the docs, both amplify-meta.json and team-provider-info.json is auto generated.

Yes, both are auto generated. The main difference being team-provider-info.json contains the parameters for all your amplify environments (assuming you have more that one and this file is shared between the team members) while amplify-meta.json contains only the info related to the currently checked out environment. In short, the values in amplify-meta.json are the ones currently used.

How does AWS Amplify cloudformation parameter.json work?

The way amplify works is by creating a cloudformation template for each function/api gateway/storage element (This is a partial list of Amplify Categories), each mini template will have its own parameters.json file (the one you mentioned). Then amplify will combine all of these files in a single template under amplify/backend/awscloudformation/nested-cloudformation-stack.yml (which is a json file!). This file will have references to each template as they get uploaded into your deployment S3 bucket (can be found in amplify-meta.json) and the contents of the parameters.json files included inline.

Upvotes: 5

Related Questions