AJ.
AJ.

Reputation: 28174

Cloudformation CLI Parameters Using Deploy Command

I'm having an issue getting the hang of using cli parameters with cloudformation deploy. I'm trying to pass in the name for the S3 bucket that I want to create, and the cli is complaining when I use --parameters to do this:

aws cloudformation deploy --template-file ../infrastructure.yml --stack-name stripe-python --parameters ParameterKey=S3BucketNameParameter,ParameterValue=lambda-artifacts-948d01bc80800b36
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: argument subcommand: Invalid choice, valid choices are:

push                                     | register                                
deregister                               | install      

 

Obviously, omitting the parameter doesn't work either:

aws cloudformation deploy --template-file ../infrastructure.yml --stack-name stripe-python 

An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameters: [S3BucketNameParameter] must have values

When I look at the documentation for cloudformation deploy, it seems to not support --parameters but instead --parameter-overrides, which I've also tried with no success:

aws cloudformation deploy --template-file ../infrastructure.yml --stack-name stripe-python --parameter-overrides S3BucketNameParameter=lambda-artifacts-948d01bc80800b36

An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameters: [S3BucketNameParameter] must have values

So, I'm kind of stumped here. Here's the template file's contents:

cat ../infrastructure.yml 
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Lambda application that calls the Stripe API to tokenize and charge credit cards
Parameters: 
  S3BucketNameParameter: 
    Type: String
    Description: Bucket name for deployment artifacts
Resources:
  S3Bucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: Retain
    Properties:
      BucketName: !Ref S3BucketNameParameter

Any suggestions on the correct approach here?

Upvotes: 1

Views: 2801

Answers (1)

Mircea
Mircea

Reputation: 10566

This works for me:

aws cloudformation deploy --template-file infrastructure.yml --stack-name stripe-python --parameter-overrides S3BucketNameParameter=lambda-artifacts-948d01bc80800b36

It may come down to awscli version (ie check the version you are running and the doc for that)

aws --version
aws-cli/2.0.44 Python/3.8.5 Darwin/18.7.0 source/x86_64

Upvotes: 2

Related Questions