首页 > 解决方案 > 使用 Deploy 命令的 Cloudformation CLI 参数

问题描述

我在掌握将 cli 参数与cloudformation deploy. 我正在尝试传递我想要创建的 S3 存储桶的名称,并且当我--parameters用来执行此操作时,cli 会抱怨:

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      

 

显然,省略参数也不起作用:

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

当我查看的文档cloudformation deploy,它似乎不支持--parameters,而是--parameter-overrides,我也尝试过但没有成功:

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

所以,我在这里有点难过。这是模板文件的内容:

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

关于正确方法的任何建议?

标签: amazon-web-servicesamazon-s3amazon-cloudformation

解决方案


这对我有用:

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

它可能归结为 awscli 版本(即检查您正在运行的版本和文档)

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

推荐阅读