英文:
AWS cloudformation: Fn:Base64:: Unable to handle special characters
问题
我已创建一个云形成脚本
# 在孟买地区(正常运行)
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64:
Fn::Sub: |
#!/bin/bash -xe
yum update -y
echo somenthing:khskhsdh >> test.txt
这会在echo somenthing:khskhsdh >> test.txt
处引发错误。
我收到的错误类似于:
如何处理特殊字符
英文:
I have created a cloud formation script
# in mumbai region (working)
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64:
Fn::Sub: |
#!/bin/bash -xe
yum update -y
echo somenthing:khskhsdh >> test.txt
this is throwing error at echo somenthing:khskhsdh >> test.txt
i get error something like:
How to handle special characters
答案1
得分: 1
我查看了所有我的模板,找到了一个百分之百有效的示例:
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64: |-
#!/bin/bash
yum update -y
echo somenthing:khskhsdh >> test.txt
问题中的 Fn::Sub:
是多余的并且导致错误。
英文:
I looked up all my templates and found an example that works 100%:
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64: |-
#!/bin/bash
yum update -y
echo somenthing:khskhsdh >> test.txt
The Fn::Sub:
in the question is redundant and causing an error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论