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.
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.
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 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? Allow customizing a stack without changing the template.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With