小编Mkr*_*yan的帖子

如何将 CloudFormation 模板转换为 terraform 代码

我有类似这样的 Cloudformation 模板

Resources:

  WafValidHostsCondition:
    Type: AWS::WAF::ByteMatchSet
    Properties:
      Name: !Sub ${AccountCode}-${RegionCode}-${Application}-waf-validhosts
      ByteMatchTuples:
        - FieldToMatch:
            Type: HEADER
            Data: host
          TargetString: !Ref PublicDns
          TextTransformation: NONE
          PositionalConstraint: EXACTLY

  WafValidHostsRule:
    Type: AWS::WAF::Rule
    Properties:
      Name: !Sub ${AccountCode}-${RegionCode}-${Application}-waf-validhosts-rule
      MetricName: WafValidHostsRule
      Predicates:
        - DataId: !Ref WafValidHostsCondition
          Negated: true
          Type: ByteMatch

  WebAcl:
    Type: AWS::WAF::WebACL
    Properties:
      Name: !Sub ${AccountCode}-${RegionCode}-${Application}-globalwebacl
      DefaultAction:
        Type: ALLOW
      MetricName: GlobalWebACL
      Rules:
        - Action:
            Type: BLOCK
          Priority: 1
          RuleId: !Ref WafValidHostsRule
Run Code Online (Sandbox Code Playgroud)

我想将其转换为地形代码。是的,我可以手动完成,但有很多:)我不想使用resource aws_cloudformation_stack,因为我们正在将所有内容从 cloudformation 迁移到 terraform。我还找到了这个工具https://github.com/ humanmade/cf- to-tf ,但是当我有现有的 CloudFormation Stack 时它可以工作。有没有办法通过工具或其他方式通过脚本来做到这一点?提前致谢

aws-cloudformation terraform

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

aws-cloudformation ×1

terraform ×1