Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Yaml cloudformation template to Json

I can't figure out how do I convert the below section of my yaml cloudformation template to a json template. Can anyone please guide me here.

Tags: 
- Key: Name 
  Value: !Join 
        - '' 
        - - !FindInMap  
              - BusinessUnitCode 
              - !Ref BusinessUnit 
              - Code 
          - A 
          - !FindInMap  
              - AWSRegionCode 
              - !Ref 'AWS::Region' 
              - Code 
          - '-' 
          - !FindInMap  
              - AccountsCode 
              - !Ref Account 
              - Code 
          - '-' 
          - !FindInMap  
              - ProdLevelCode 
              - !Ref ProductionLevel 
              - Code 
          - '-' 
          - !FindInMap  
              - ServerFunctionCode 
              - !Ref ServerFunction 
              - Code 
          - '-' 
          - !FindInMap  
              - SGFunctionCode 
              - !Ref SecurityGroupFunction 
              - Code 
          - '-'                   
          - !Ref IncrementCode

Though I know there is no need for this conversion as both json and yaml works the same in cloudformation, have to do this as per a mandate.

like image 630
Naxi Avatar asked Aug 13 '19 08:08

Naxi


People also ask

Can you convert YAML to JSON?

To convert a YAML document to JSON, follow these steps: Select the YAML to JSON action from the XML Tools > JSON Tools menu. Choose or enter the YAML URL for the document you want to convert. Choose the path of the Output file that will contain the resulting JSON document.

Should I use YAML or JSON with CloudFormation?

YAML CloudFormation fully supports all of the same features and functions as JSON CloudFormation with some additional features to reduce the length of code and increase readability. Say goodbye to the curly braces and most of the quotation marks of JSON when you use YAML.

How can I reuse CloudFormation template?

You simply create a separate template for the resources that you want to reuse and then save that template in an Amazon S3 bucket. Whenever you want to add those resources in another template, use the AWS::CloudFormation::Stack resource to specify the S3 URL of the nested template.

Does CloudFormation use JSON?

For more information about the template syntax for each format, see Template anatomy. AWS CloudFormation follows the ECMA-404 JSON standard. For more information about the JSON format, see http://www.json.org . AWS CloudFormation supports the YAML Version 1.1 specification with a few exceptions.


1 Answers

AWS Console can help you with that. Open your CloudFormation template in template designer.

CloudFormation > Select your stack > Template > View in designer

You can then easily convert your template by choosing your template language as Json.

like image 127
Vikyol Avatar answered Sep 20 '22 12:09

Vikyol