gpt4 book ai didi

amazon-web-services - AWS CloudFormation - 将参数( key 对)从 Azure DevOps 添加到 json

转载 作者:行者123 更新时间:2023-12-03 03:42:12 25 4
gpt4 key购买 nike

AWS 上提供了一个 VPC Basic cloudformation 模板。这是代码的链接:https://s3.us-west-2.amazonaws.com/cloudformation-templates-us-west-2/VPC_Single_Instance_In_Subnet.template

当我使用 CloudFormation 创建它时,除非我使用 GUI 指定 key 对,否则它会失败。当我指定 key 对时,它就起作用了。

问题是,我正在尝试使用 AWS 的集成工具包从 AzureDevOps 运行此 cloudformation 模板。

目前,我执行此操作的方式是,仅传递指向模板文件的链接。模板文件包含 JSON 格式的模板,但我不确定是否:

a)我应该在上面链接的模板文件中插入 key 对名称

或者

b)还有其他方式吗?

我正在使用 AWS 工具包进行 Azure DevOps

这是我的代码:

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: CloudFormationCreateOrUpdateStack
inputs:
awsCredentials: 'aws_test'
regionName: 'us-west-2'
stackName: 'test'
templateSource: 'url'
templateUrl: 'https://s3.us-west-2.amazonaws.com/cloudformation-templates-us-west-2/VPC_Single_Instance_In_Subnet.template'
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'

运行时出现的错误是参数KeyPair需要一个值。

最佳答案

如果您想要使用预定义的 key ,则可以设置默认值:

    "KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"Default": "your-key-pari-name",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
},

这样您就不必显式设置其值,除非它与默认值不同。

关于amazon-web-services - AWS CloudFormation - 将参数( key 对)从 Azure DevOps 添加到 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70676098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com