내용으로 건너뛰기

Attached ENI trunk to custom security group in cloudformation

0

I recently enabled ENI trunking feature in ECS. An extra ENI interface is created and attached to the default security group.

Cloudformation (ec2 launch template) is use to launch the ec2 instance. How do I attached the extra interface with custom security group in launch template?

ECSAutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      AutoScalingGroupName: MyECSAutoScalingGroup
      VPCZoneIdentifier: !Ref Subnets
      MixedInstancesPolicy:
        LaunchTemplate:
          LaunchTemplateSpecification:
            LaunchTemplateId: !Ref ECSLaunchTemplate
            Version: !GetAtt ECSLaunchTemplate.LatestVersionNumber
      MinSize: !Ref ClusterSize
      MaxSize: !Ref ClusterMaxSize
      DesiredCapacity: !Ref DesiredSize

  ECSLaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: MyECSLaunchTemplate
      LaunchTemplateData: 
        KeyName: MyKey
        ImageId: !Ref ImageId
        InstanceType: !Ref InstanceType
        SecurityGroupIds:
          - !Ref SecurityGroup
        IamInstanceProfile:
          Arn: !GetAtt ECSInstanceProfile.Arn

질문됨 4년 전621회 조회

1개 답변
0

you can use the following - please update accordingly

"NetworkInterfaces": [
    {
        "AssociatePublicIpAddress": false,
        "DeviceIndex": "1",
        "GroupSet": [
            "sg-xxxxxx" // add the ID of your custom security group here
        ],
        "NetworkInterfaceId": {
            "Fn::ImportValue": "<NameOfExportedValue>" // add the name of the exported value for the ENI interface here
        }
    }
]

전문가

답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠