1 Answer
- Newest
- Most votes
- Most comments
1
From your post, I have noticed that you are using both wait condition handle and CreationPolicy and the syntax is also used incorrectly.
For Amazon EC2 and Auto Scaling resources, we recommend that you use a CreationPolicy attribute instead of wait conditions. Add a CreationPolicy attribute to those resources, and use the cfn-signal helper script to signal when an instance creation process has completed successfully.
You can use a wait condition for situations like the following:
- To coordinate stack resource creation with configuration actions that are external to the stack creation.
- To track the status of a configuration process.
For these situations, we recommend that you associate a CreationPolicy attribute with the wait condition so that you don't have to use a wait condition handle. For more details please refer to our public document
Below is the sample Cloudformation template -
Parameters:
InstanceKey:
Type: 'AWS::EC2::KeyPair::KeyName'
Resources:
DBEC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: ami-xxxxxxxxxxxx
KeyName: !Ref InstanceKey
InstanceType: m5.large
SecurityGroupIds:
- !Ref InstanceSecurityGroup
UserData: !Base64
'Fn::Sub': |
<powershell>
# START LOG.
$lastexitcode = 0
$timestamp = Get-Date -Format yyyyMMdd-hhmm
write " Date: $timestamp."
# CALL CUSTOM UTILITY
write "running CustomUtility."
cfn-signal.exe -e $lastexitcode --stack ${AWS::StackName} --resource WaitCondition --region ${AWS::Region}
</powershell>
WaitCondition:
Type: 'AWS::CloudFormation::WaitCondition'
CreationPolicy:
ResourceSignal:
Timeout: PT5M
Count: 1
InstanceSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Allow ssh on the instance
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3389
ToPort: 3389
CidrIp: x.x.x.x/x
Relevant content
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 10 months ago
Thank you for your help. However, it is not working. As you can see my code, I tried WaitConditionHandle, but it is not linked to any other resource. So, I am not sure, whether there will be any impact. Also, the documentation is not very clear on how to get this working. I have a couple of more questions, though.