Я пытаюсь выполнить несколько команд powershell в экземпляре Amazon EC2 Windows с помощью cfn-init.Если я добавлю cfn-signal и CreationPolicy, cfn-init не будет выполнен.Без добавления cfn-signal и Creation Policy все выполняется и работает нормально.Вот часть моего сценария:
EC2Instance1:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
files:
'c:\cfn\cfn-hup.conf':
content: !Join
- ''
- - |
[main]
- stack=
- !Ref 'AWS::StackId'
- |+
- region=
- !Ref 'AWS::Region'
- |+
'c:\cfn\hooks.d\cfn-auto-reloader.conf':
content: !Join
- ''
- - |
[cfn-auto-reloader-hook]
- |
triggers=post.update
- >
path=Resources.EC2Instance1.Metadata.AWS::CloudFormation::Init
- 'action=cfn-init.exe -v -s '
- !Ref 'AWS::StackId'
- ' -r EC2Instance1'
- ' --region '
- !Ref 'AWS::Region'
- |+
commands:
1-createFile:
command: !Sub |
powershell.exe New-Item ${PathOfFile} -ItemType file
2-addContenttoFile:
command: !Sub |
powershell.exe Set-Content -path ${PathOfFile} -Value 'Ip of webserver1 here'
3-replaceText:
command: !Sub |
powershell.exe (Get-Content ${PathOfFile}).replace('webserver1', (Invoke-WebRequest ifconfig.me/ip).Content.Trim()) ^| Set-Content ${PathOfFile}
Properties:
ImageId: !Ref AMI1
InstanceType: !Ref EC2InstanceType
KeyName: !Ref KeyName
UserData: !Base64
'Fn::Join':
- ''
- - |
<script>
- 'cfn-init.exe -v -s '
- !Ref 'AWS::StackId'
- ' -r EC2Instance1'
- ' --region '
- !Ref 'AWS::Region'
- |+
- |
- 'cfn-signal.exe -e %ERRORLEVEL% -s --stack '
- !Ref 'AWS::StackName'
- ' --resource EC2Instance1'
- ' --region '
- !Ref 'AWS::Region'
- |+
- </script>
CreationPolicy:
ResourceSignal:
Count: "1"
Timeout: PT10M
Где я ошибаюсь?