Home > other >  Whitelist a resource in cloudformation
Whitelist a resource in cloudformation

Time:08-12

I am working with cloudformation. I am creating a security group for RDS and trying to white list the EC2 private ip. But it is failed to create security group

  TestSecuri:
    Type: AWS::EC2::SecurityGroup
    DependsOn: EC2Instance
    Properties:
      GroupDescription: allow connections from specified CIDR ranges
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 800
        ToPort: 800
        CidrIp: !GetAtt "EC2Instance.PrivateIp/32"

CodePudding user response:

You can just do with Sub:

CidrIp: !Sub "{EC2Instance.PrivateIp}/32"

CodePudding user response:

You'll need to use Fn::Join if you want to create the desired string:

CidrIp: 
  Fn::Join: 
    - '/'
    - - Fn::GetAtt:
        - EC2Instance
        - PrivateIp
      - '32'
  • Related