Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 513
Khon Lieu Avatar asked Aug 26 '19 12:08

Khon Lieu


People also ask

How do you reference a parameter in CloudFormation?

Referencing a parameter within a template You use the Ref intrinsic function to reference a parameter, and AWS CloudFormation uses the parameter's value to provision the stack. You can reference parameters from the Resources and Outputs sections of the same template.

Does AWS amplify use CloudFormation?

Today, the Amplify Console launched support for AWS CloudFormation resources to give developers the ability to have reliable and repeatable access to the Amplify Console service.

How does amplify work?

How does AWS Amplify Work? Using AWS Amplify, you can add, integrate and interact with AWS cloud services through this component. The library also facilitates safe authentication, storage of files, data stocking, serverless APIs, analytics, push notifications, AR/VR, and multiple other applications' features.

What's an advantage of using parameters in a CloudFormation template?

What's an advantage of using parameters in a CloudFormation template? Allow customizing a stack without changing the template.


Video Answer


1 Answers

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.

  • More info about these nested templates can be found AWS Cloudformation User Guide
  • More info about Amplify CLI inner workings can be found Amplify Usage and Amplify Architecture
like image 152
Samih3 Avatar answered Oct 11 '22 19:10

Samih3