title: AWS CDK assign Elastic IP to Elastic Beanstalk Single Instance
body: <p>I am trying to assign an existing <code>Elastic IP</code> to an EC2 instance in a <strong>SingleInstance</strong> <code>Elastic Beanstalk</code> environment created with CDK.</p>
  <p>However, I could not find out:</p>
  <ul>
  <li>How to get the <strong>reference</strong> to an existing <code>Elastic IP</code> with CDK</li>
  <li>How to get the <strong>reference</strong> to the EC2 instance created by the <code>Elastic Beanstalk</code> Environment</li>
  <li>How to <strong>allocate</strong> the <code>Elastic IP</code> to that Instance</li>
  </ul>
  <p>Environment Source</p>
  <pre><code>  const environment = new elasticbeanstalk.CfnEnvironment(this, `somename`, {
          applicationName: 'someappname',
          environmentName: 'someenvname',
          platformArn:
              'arn:aws:elasticbeanstalk:eu-central-1::platform/Node.js 16 running on 64bit Amazon Linux 2/5.5.0',
          optionSettings: [
              {
                  namespace: 'aws:elasticbeanstalk:environment',
                  optionName: 'EnvironmentType',
                  value: 'SingleInstance',
              },
              {
                  namespace: 'aws:autoscaling:launchconfiguration',
                  optionName: 'InstanceType',
                  value: 't3.small',
              },
              {
                  namespace: 'aws:autoscaling:launchconfiguration',
                  optionName: 'IamInstanceProfile',
                  value: 'aws-elasticbeanstalk-ec2-role',
              },
          ],
          versionLabel: applicationVersion.ref,
      });
  </code></pre>