【问题标题】:Cloudformation CLI Parameters Using Deploy Command使用 Deploy 命令的 Cloudformation CLI 参数
【发布时间】:2020-10-11 05:40:39
【问题描述】:

我在使用带有 cloudformation deploy 的 cli 参数时遇到问题。我正在尝试传递我想要创建的 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

当我查看the documentation for 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-services amazon-s3 amazon-cloudformation


    【解决方案1】:

    这对我有用:

    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
    

    【讨论】:

      猜你喜欢
      • 2019-09-16
      • 1970-01-01
      • 2016-02-23
      • 2022-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-22
      • 1970-01-01
      相关资源
      最近更新 更多