Skip to content

Instantly share code, notes, and snippets.

@ilyasotkov
Last active August 19, 2020 04:01
Show Gist options
  • Save ilyasotkov/1cdbcc66f4dd854fcd4e9a04d955ce43 to your computer and use it in GitHub Desktop.
Save ilyasotkov/1cdbcc66f4dd854fcd4e9a04d955ce43 to your computer and use it in GitHub Desktop.
CloudFormation YAML Parameter Values with yq (https://github.com/kislyuk/yq)
# ./template.yaml
AWSTemplateFormatVersion: 2010-09-09

Parameters:
  BucketName:
    Type: String
    
Resources:
  Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Ref BucketName
# ./params.yaml
BucketName: my-bucket-xyz
#!/bin/bash

# ./deploy.sh

stack_name=my-stack
template_path=./template.yaml
parameter_values_path=./params.yaml

aws cloudformation deploy \
    --stack-name $stack_name \
    --template-file $template_path \
    --parameter-overrides $(yq -r 'to_entries | .[] | "\(.key)=\(.value)"' $parameter_values_path) \
    --no-fail-on-empty-changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment