AWS CloudFormation: Fn::Base64:: 无法处理特殊字符

huangapple go评论62阅读模式
英文:

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处引发错误。

我收到的错误类似于:

AWS CloudFormation: Fn::Base64:: 无法处理特殊字符

如何处理特殊字符

英文:

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

AWS CloudFormation: Fn::Base64:: 无法处理特殊字符

i get error something like:

AWS CloudFormation: Fn::Base64:: 无法处理特殊字符

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.

huangapple
  • 本文由 发表于 2023年7月20日 15:39:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76727650.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定