有没有办法在Amazon Cloudformation中解析EMR MasterPublicDNS?

时间:2019-01-22 23:30:10

标签: amazon-cloudformation

有没有一种方法可以解析Cloudformation中的EMR MasterPublicDNS?我在Cloudformation中看不到替换功能。

ip-100-112-10-21.aws.internal

TO

100.112.10.21

Outputs:
  IPAddress:
    Description: IP address of the EMR clusters
    Value: !GetAtt
      - EMRCluster
      - MasterPublicDNS
can I reference the output value in same script?
I need to use the formatted IP to set resourcerecords- or do I have to use 
Type: AWS::Route53::RecordSetGroup
 ResourceRecords: !Join [".",
      [
        !Select [1, !Split ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select [2, !Split ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select [3, !Split ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select [0,
          !Split ['.', !Select [4, !Split ['-', !GetAtt EMRCluster.MasterPublicDNS]]]]
      ]
    ]

 gives error - Value of property ResourceRecords must be of type List of String
 or 
 ResourceRecords: !ref IPAddress.value

1 个答案:

答案 0 :(得分:0)

如果格式总是这样,则可以结合使用SplitSelectJoin Cloudformation intrinsic functions来实现:

Outputs:
  IPAddress:
    Description: IP address of the EMR clusters
    Value: !Join ['.',
      [
        !Select: [1, !Split: ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select: [2, !Split: ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select: [3, !Split: ['-', !GetAtt EMRCluster.MasterPublicDNS]],
        !Select: [0,
          !Split: ['.', !Select: [4, !Split: ['-', !GetAtt EMRCluster.MasterPublicDNS]]]]
      ]
    ]

我知道这会让您感到畏惧,但这就是Cloudformation的方法。

或者,您可以编写一个Cloudformation macro来帮您完成此任务。