我花了很多时间来弄清楚为什么我的 CloudFormation 模板使用 WaitCondition 失败。模板错误输出:WaitCondition timed out. Received 0 conditions when expecting 1. 请注意,我确实确保我的 AMI 在我的 AMI 中预装了 cfn-signal 命令。
我附上了我的模板的以下屏幕截图:

我用谷歌搜索,发现有些人有同样的问题,比如:http : //virtuallyhyper.com/2013/02/cloudformation-waitcondition-timed-out-error/。但是,就我而言, cfn-signal 命令确实存在。所以直到现在我仍然不知道如何解决这个问题。
谢谢
我对 AWS CloudFormation 模板完全陌生,我是一名 Python Web 开发人员。但是突然我的经理让我(根据客户的要求)检查是否 -我们可以创建一个通用的 AWS CloudFormation 模板来为跨多个账户的所有区域创建/更新资源。
所以,我用谷歌搜索了它,但我对 CloudFormation 区域映射没有太多了解。因为我很难在短时间内完全理解 Cloudformation。
所以,我很好奇这可能吗?
示例:假设我必须在所有区域的 3 个账户中创建一个 S3 存储桶。
{
"Resources" : {
"some-bucket" : {
"Type" : "AWS::S3::Bucket"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果这种情况可能发生,有人可以指导我吗?如果是这样的话
我可以添加 1 个变量但无法添加第二个,我是系统管理员,对 YAML 了解不多
UserData:
Fn::Base64: !Sub
- |+
#!/bin/bash -xe
NEW_HOSTNAME=${test}
- test:
Fn::FindInMap: [Regions, !Ref "AWS::Region", Name]
Run Code Online (Sandbox Code Playgroud)
我想在测试后添加另一个 FindInMap 变量,但我无法添加。
我有以下非常简单的CloudFormation模板:
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
InstanceType:
Description: 'EC2 Instance Type'
Default: t2.micro
Resources:
EC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: ami-08589eca6dcc9b39c
InstanceType: !Ref InstanceType
KeyName: default
Run Code Online (Sandbox Code Playgroud)
在使用以下方法验证此模板时:
? aws cloudformation validate-template --template-body file://cloudformation.yml
Run Code Online (Sandbox Code Playgroud)
我收到以下神秘错误消息:
An error occurred (ValidationError) when calling the ValidateTemplate operation:
Template format error: Every Parameters object must contain a Type member.
Run Code Online (Sandbox Code Playgroud)
这是什么意思?我在Google上搜索了此错误消息,却一无所获。
我正在以云形式创建 EFS 卷并尝试在启动模板的用户数据中引用它。
我尝试了在 CF 中使用 Ref 的多种语法,但每次都遇到相同的错误。我实际上想用 EFS 做不同的事情,但发布的示例代码也不起作用
ClusterFileSystem:
Type: AWS::EFS::FileSystem
Properties:
Encrypted: true
ClusterLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
DependsOn: ClusterFileSystem
Properties:
LaunchTemplateName: !Sub ${AWS::StackName}
LaunchTemplateData:
ImageId: !Ref 'AMIId'
SecurityGroupIds: [!GetAtt 'ClusterSecurityGroup.GroupId']
InstanceType: !Ref 'InstanceType'
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
VolumeSize: "40"
VolumeType: "gp2"
Encrypted: true
- DeviceName: "/dev/xvdcz"
Ebs:
VolumeSize: "22"
VolumeType: "gp2"
Encrypted: true
IamInstanceProfile:
Name: 'ECSHostInstanceProfile'
Monitoring:
Enabled: true
KeyName: !Ref 'Key'
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
function setup-efs () {
{
mkdir -p /ecs-resources/${AWS::StackName}/environment
EFS_FILE_SYSTEM_ID= …Run Code Online (Sandbox Code Playgroud) 我有两个嵌套的 Cloudformation 堆栈 - 第一个模板需要定义 Kinesis 流,第二个需要使用对该流的 ARN 的引用,作为进一步嵌套堆栈的参数。
因此,似乎我需要从第一个模板“导出”流,并将其“导入”到第二个模板中(遵循有关跨堆栈导入/导出值的 AWS 文档)-
我的导出代码 [截断] 看起来像这样 -
Outputs:
MyKinesisStreamOutput:
Value:
Ref: MyKinesisStream
Export:
Name: my-kinesis-stream
Resources:
MyKinesisStream:
Properties:
Name:
Ref: AppName
ShardCount: 1
Type: AWS::Kinesis::Stream
Run Code Online (Sandbox Code Playgroud)
虽然我的导入代码 [截断] 看起来像这样 -
MyNestedStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub "https://s3.${AWS::Region}.amazonaws.com/my-nested-stack.yaml"
Parameters:
AppName: my-nested-stack
KinesisStream:
Fn::GetAtt:
- Fn::ImportValue:
my-kinesis-stream
- Arn
Run Code Online (Sandbox Code Playgroud)
但是后来我收到以下 Cloudformation 错误 -
Template error: every Fn::GetAtt object requires two non-empty parameters, the resource name and the resource attribute
Run Code Online (Sandbox Code Playgroud)
并怀疑我犯了这个 -
For the …Run Code Online (Sandbox Code Playgroud) 按照有关 AWS 实例调度的教程,我能够创建一个新的 EC2instanceScheduler 云形成堆栈。
但是,每次我尝试更新该堆栈时,都会发生以下错误:
需要能力:[CAPABILITY_IAM]
我搜索了信息,但似乎找不到任何关于这是什么、这意味着什么以及如何激活它的明确信息。
在此页面上,亚马逊表示如下:
在某些情况下,您必须明确承认您的堆栈模板包含某些功能,以便 AWS CloudFormation 创建堆栈。
但我似乎无法理解如何以及在哪里。有人可以给我关于这个主题的明确信息吗?这个错误是什么意思,我该如何解决?
所以,我目前遇到了这个问题,但没有多大意义,因为我已经添加了类型LoadBalancerListener......我之前已经测试过Load Balancer和Target Group,然后它们运行良好,但是当我添加时Listener,堆栈得到一个错误。这是代码:
AWSTemplateFormatVersion: 2010-09-09
Description: Template for load balancer
Resources:
DayOne:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Scheme: internet-facing
SecurityGroups:
- sg-055ea833725644075
Subnets:
- subnet-0d7b9bf57973e6b78
- subnet-0186890795288d48a
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
- TargetGroupArn: !Ref TargetGroup
LoadBalancerArn: !Ref DayOne
Port: 80
Protocol: "HTTP"
TargetGroup:
DependsOn: "DayOne"
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
TargetType: "instance"
Name: "DayOneTarget"
Port: 80
Protocol: "HTTP"
VpcId: "vpc-0f98d22c9291e3c0c"
HealthyThresholdCount: 2
HealthCheckTimeoutSeconds: 10
HealthCheckIntervalSeconds: 30
Run Code Online (Sandbox Code Playgroud)
这是问题所在:
cloud amazon-web-services aws-cloudformation aws-load-balancer
我试图每 2 小时从 CLoudwatch 触发一次 AWS 任务计划,这将执行一些操作。
下面是我的 Cloudformation 模板
TaskSchedule:
Type: "AWS::Events::Rule"
DeletionPolicy: Delete
Properties:
Description: >
Run every two hours.
ScheduleExpression: !Ref TaskRate #rate(1 day) #cron (15 10 * * ? *) #(0 0 * * *) #!Ref LambdaRate
State: ENABLED
#Targets:
# - Arn: !Ref ecsCluster.Arn #!Sub ${TaskDefinitionDaily.Arn}
# Id: TaskSchedule
# EcsParameters:
# TaskDefinitionArn: !Ref TaskDefinitionDaily
# TaskCount: 1
# LaunchType: 'FARGATE'
# PlatformVersion: 'LATEST'
Targets:
- Id: 'ECSTarget'
Arn: !Ref ecsCluster.Arn #!Sub ${TaskDefinitionDaily.Arn}
EcsParameters:
TaskCount: …Run Code Online (Sandbox Code Playgroud) 我有一个用于通过 CDK 部署的 api 的 OpenAPI 规范。规范看起来像:
openapi: 3.0.1
info:
title: My API
description: My REST API with CORS enabled
version: 0.1.0
x-amazon-apigateway-cors:
allowOrigins:
- "*"
allowCredentials: true
exposeHeaders:
- "x-apigateway-header"
- "x-amz-date"
- "content-type"
maxAge: 3600
allowMethods:
- "*"
allowHeaders":
- "x-apigateway-header"
- "x-amz-date"
- "content-type"
- "Authorization"
components:
securitySchemes:
lambda:
type: "apiKey"
name: "Authorization"
in: "header"
x-amazon-apigateway-authtype: "custom"
x-amazon-apigateway-authorizer:
authorizerUri: "{{my-lambda-authorizer}}"
authorizerResultTtlInSeconds: 300
type: "token"
paths:
/user/{id}:
get:
summary: Get info of specified user.
parameters:
- in: path …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-cloudformation aws-lambda aws-api-gateway aws-cdk