How to create secondary private ip with AWS CDK?

0

I cannot figure out how I can attach a secondary private IP to my primary ENI (eth0) with AWS CDK.

This is how I create my instance:

   const myVpc = new ec2.Vpc(this, "my-vpc", {
      maxAzs: 3,
    });

   const mySecurityGroup = ...
  const imageDebian10 = ...
    
    new ec2.Instance(this, "my-instance", {
      instanceName: "my-instance",
      vpc: myVpc,
      vpcSubnets: {
        subnetType: ec2.SubnetType.PUBLIC,
      },
      availabilityZone: this.availabilityZones[0],
      securityGroup: mySecurityGroup,
      machineImage: imageDebian10,
      instanceType: ec2.InstanceType.of(
        ec2.InstanceClass.T2,
        ec2.InstanceSize.MICRO
      ),
    });
TheBlob
질문됨 2년 전1065회 조회
1개 답변
0

Hello

As far as i know that you cannot modify the Primary interface, Here are my recommendations for you, I have done something like this with Cloud-formation both any stack could be the same.

Procedure:

  • Create Two interaces or one interface eni(0) [I have created manually because there is custom requirement for us ]
  • You can call One is primary and Second Interface as Secondary ENI
  • You can refer those interfaces in your template

Primary network interface

Each instance has a default network interface, called the primary network interface. You cannot detach a primary network interface from an instance. You can create and attach additional network interfaces. The maximum number of network interfaces that you can use varies by instance type. For more information, see IP addresses per network interface per instance type.

If you still have any questions please let me know

Thank You GK

profile picture
전문가
GK
답변함 2년 전

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

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

질문 답변하기에 대한 가이드라인

관련 콘텐츠