DEV Community

DEV Community

Kóredé Bashir

Posted on Jun 22, 2022

How to Add a Static IP to an AWS EC2 Instance

Introduction.

AWS Elastic Compute Cloud (EC2) is a popular option for cloud computing services. It offers virtual servers (or instances) as well as security, networking, and storage options. EC2 can launch as many or as few virtual servers as you need, depending on your projects.

Using EC2 offers multiple benefits, including the ability to run your applications in the cloud and to create virtual machines (VMs) with whatever configurations you might need. The infrastructure is scalable, with over 500 instances, and EC2 supports developing macOS and machine learning applications.

EC2 works with static (aka elastic) IP addresses. Whenever a resource on a network is assigned an IP address, that IP address is either dynamic—meaning it’s assigned by the network it’s connected to and changes periodically—or static, meaning it never changes. An elastic IP address in EC2 is public, so it’s reachable from the internet. Because it’s set to your AWS account, an elastic IP address can be remapped to another instance as needed in case of bugs or other issues. A custom IP address can also be added to your account rather than use one from AWS.

Elastic IP addresses are provided via a Dynamic Host Configuration Protocol (DHCP). These IP addresses are persistent, meaning they will not change when the VM is restarted or shut down.

In this tutorial, I'll walk you through how to configure an elastic IP address with an AWS EC2 instance.

Prerequisites

This article doesn't have many prerequisites, it is a tutorial which will assume you already have an AWS EC2 instance provisioned already, that is ready to be associated with an elastic IP address. In case you do not already have an AWS EC2 instance running, please create one before proceeding with the rest of this guide.

Let's dive right in!

Step 1: Choosing Elastic IP

From the AWS console, navigate to EC2 by clicking Compute . This should take you straight to your EC2 dashboard.

Navigate to dashboard

On your dashboard, click on Elastic IPs under Network & Security .

Elastic IPs

Step 2: Creating New IP

Click on Allocate Elastic IP address to create a new static IP address.

Allocate IP

Proceed by clicking Allocate .

IP options

Step 3: Assigning IP to EC2 Instance

Once the allocation request is successful, assign the static IP to your EC2 instance.

On the elastic IP view, select the IP you just allocated and click the Actions dropdown.

Actions menu

Select the View details button to reveal the info page on the elastic IP.

Elastic IP details

On this page, click the Associate Elastic IP address button.

Associate IP address

Step 4: Associating IP to Instance

Search for your instance ID from the Instance field.

Locate instance ID

Select the instance ID and scroll down to click the Associate button.

Associate IP

Step 5: Checking The Instance View

Your elastic IP address has now been associated with your EC2 instance. Head to your instance view by clicking on your instance ID. The address of your static IP is now displayed on the view.

IP associated successfully

Step 6: Connecting to The Instance

Connect to your EC2 instance with the newly associated static IP. On your instance view, click Connect . A view with connection details can now be seen. If you’re using a Linux or Mac system, open up your terminal.

Instance summary

Select SSH on the connect view. This tutorial connects via SSH through PowerShell.

Connect to instance

Set permissions on private key if you haven’t already by pasting one of the below commands in your terminal or CLI:

Option A: Linux

Set permissions on Linux for private key

Option B: Windows (PowerShell)

Set permissions on Windows for private key

You can copy-paste the second command shown on your instance description to connect to your remote instance:

Connect to EC2 instance

Enter Yes to proceed.

CLI connected to instance

The instance is now connected, as shown below, this was validated by confirming the present working directory with the command pwd . Please proceed with building whatever solution you want to deploy on your EC2 instance.

Connected EC2 instance

Limits on Elastic IPs

According to this AWS documentation on service quotas, “Your AWS account has default quotas, formerly referred to as limits, for each AWS service.” The important thing to understand is that static IPs on EC2 instances have a limit of five IPs per region per account, so you can’t allocate more than five static IPs in the same AWS region. If you already have up to five elastic IPs, you can either delete one or select a new AWS region before allocating a new IP.

If you need to confirm your elastic IP address limit, head over to your EC2 dashboard. Select Limits from the left pane and type in IP in the search box. You should immediately see the EC2-VPC Elastic IPs limit. Click on it for more details about the limit quota.

Remember, the good thing about elastic IPs is they don’t change or expire, unless they are disassociated from an instance and released.

Request an increase to your quota from the Service Quotas Console if the need arises.

In this tutorial, you learned how to set up an elastic IP address and connect it remotely with your AWS EC2 instance. As you saw, this is a simple process that gives you more control over your EC2 instance and allows you to choose your own IP address for as long as you need it.

If you have any questions, feel free to reach out to me on Twitter: @ John Doe or LinkedIn

Top comments (0)

pic

Templates let you quickly answer FAQs or store snippets for re-use.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .

Hide child comments as well

For further actions, you may consider blocking this person and/or reporting abuse

yeauxdejuan profile image

Reverse engineering in the gaming industry

De'Juan Ellsworth - Nov 28

mlewis7127 profile image

Using Amazon Q to deliver customer value

Matt Lewis - Nov 28

akram6t profile image

Use socket.io in react native with nodejs server

AKram Khan - Nov 28

favilo profile image

Working through the fast.ai book in Rust - Part 6

Favil Orbedios - Nov 28

Once suspended, bashirk will not be able to comment or publish posts until their suspension is removed.

Once unsuspended, bashirk will be able to comment and publish posts again.

Once unpublished, all posts by bashirk will become hidden and only accessible to themselves.

If bashirk is not suspended, they can still re-publish their posts from their dashboard.

Once unpublished, this post will become invisible to the public and only accessible to Kóredé Bashir.

They can still re-publish the post if they are not suspended.

Thanks for keeping DEV Community safe. Here is what you can do to flag bashirk:

bashirk consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy.

Unflagging bashirk will restore default visibility to their posts.

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

AWS::EC2::Instance

Specifies an EC2 instance.

If an Elastic IP address is attached to your instance, AWS CloudFormation reattaches the Elastic IP address after it updates the instance. For more information about updating stacks, see AWS CloudFormation Stacks Updates .

To declare this entity in your AWS CloudFormation template, use the following syntax:

This property is reserved for internal use. If you use it, the stack fails with this error: Bad property set: [Testing this property] (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 0XXXXXX-49c7-4b40-8bcc-76885dcXXXXX) .

Required : No

Type : String

Update requires : No interruption

Indicates whether the instance is associated with a dedicated host. If you want the instance to always restart on the same host on which it was launched, specify host . If you want the instance to restart on any available host, but try to launch onto the last host it ran on (on a best-effort basis), specify default .

The Availability Zone of the instance.

If not specified, an Availability Zone will be automatically chosen for you based on the load balancing criteria for the Region.

This parameter is not supported by DescribeImageAttribute .

Update requires : Replacement

The block device mapping entries that defines the block devices to attach to the instance at launch.

By default, the block devices specified in the block device mapping for the AMI are used. You can override the AMI block device mapping using the instance block device mapping. For the root volume, you can override only the volume size, volume type, volume encryption settings, and the DeleteOnTermination setting.

After the instance is running, you can modify only the DeleteOnTermination parameter for the attached volumes without interrupting the instance. Modifying any other parameter results in instance replacement .

Type : Array of BlockDeviceMapping

The CPU options for the instance. For more information, see Optimize CPU options in the Amazon Elastic Compute Cloud User Guide .

Type : CpuOptions

The credit option for CPU usage of the burstable performance instance. Valid values are standard and unlimited . To change this attribute after launch, use ModifyInstanceCreditSpecification . For more information, see Burstable performance instances in the Amazon EC2 User Guide .

Default: standard (T2 instances) or unlimited (T3/T3a/T4g instances)

For T3 instances with host tenancy, only standard is supported.

Type : CreditSpecification

If you set this parameter to true , you can't terminate the instance using the Amazon EC2 console, CLI, or API; otherwise, you can. To change this attribute after launch, use ModifyInstanceAttribute . Alternatively, if you set InstanceInitiatedShutdownBehavior to terminate , you can terminate the instance by running the shutdown command from the instance.

Default: false

Type : Boolean

Indicates whether the instance is optimized for Amazon EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal Amazon EBS I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS-optimized instance.

An elastic GPU to associate with the instance. An Elastic GPU is a GPU resource that you can attach to your Windows instance to accelerate the graphics performance of your applications. For more information, see Amazon EC2 Elastic GPUs in the Amazon EC2 User Guide .

Type : Array of ElasticGpuSpecification

An elastic inference accelerator to associate with the instance. Elastic inference accelerators are a resource you can attach to your Amazon EC2 instances to accelerate your Deep Learning (DL) inference workloads.

You cannot specify accelerators from different generations in the same request.

Starting April 15, 2023, AWS will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, Amazon ECS, or Amazon EC2. However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service.

Type : Array of ElasticInferenceAccelerator

Indicates whether the instance is enabled for AWS Nitro Enclaves.

Type : EnclaveOptions

Indicates whether an instance is enabled for hibernation. This parameter is valid only if the instance meets the hibernation prerequisites . For more information, see Hibernate your instance in the Amazon EC2 User Guide .

You can't enable hibernation and AWS Nitro Enclaves on the same instance.

Type : HibernationOptions

If you specify host for the Affinity property, the ID of a dedicated host that the instance is associated with. If you don't specify an ID, Amazon EC2 launches the instance onto any available, compatible dedicated host in your account. This type of launch is called an untargeted launch. Note that for untargeted launches, you must have a compatible, dedicated host available to successfully launch instances.

The ARN of the host resource group in which to launch the instances. If you specify a host resource group ARN, omit the Tenancy parameter or set it to host .

The name of an IAM instance profile. To create a new IAM instance profile, use the AWS::IAM::InstanceProfile resource.

The ID of the AMI. An AMI ID is required to launch an instance and must be specified here or in a launch template.

Required : Conditional

Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

Default: stop

Allowed values : stop | terminate

The instance type. For more information, see Instance types in the Amazon EC2 User Guide .

When you change your EBS-backed instance type, instance restart or replacement behavior depends on the instance type compatibility between the old and new types. An instance with an instance store volume as the root volume is always replaced. For more information, see Change the instance type in the Amazon EC2 User Guide .

Allowed values : a1.2xlarge | a1.4xlarge | a1.large | a1.medium | a1.metal | a1.xlarge | c1.medium | c1.xlarge | c3.2xlarge | c3.4xlarge | c3.8xlarge | c3.large | c3.xlarge | c4.2xlarge | c4.4xlarge | c4.8xlarge | c4.large | c4.xlarge | c5.12xlarge | c5.18xlarge | c5.24xlarge | c5.2xlarge | c5.4xlarge | c5.9xlarge | c5.large | c5.metal | c5.xlarge | c5a.12xlarge | c5a.16xlarge | c5a.24xlarge | c5a.2xlarge | c5a.4xlarge | c5a.8xlarge | c5a.large | c5a.xlarge | c5ad.12xlarge | c5ad.16xlarge | c5ad.24xlarge | c5ad.2xlarge | c5ad.4xlarge | c5ad.8xlarge | c5ad.large | c5ad.xlarge | c5d.12xlarge | c5d.18xlarge | c5d.24xlarge | c5d.2xlarge | c5d.4xlarge | c5d.9xlarge | c5d.large | c5d.metal | c5d.xlarge | c5n.18xlarge | c5n.2xlarge | c5n.4xlarge | c5n.9xlarge | c5n.large | c5n.metal | c5n.xlarge | c6a.12xlarge | c6a.16xlarge | c6a.24xlarge | c6a.2xlarge | c6a.32xlarge | c6a.48xlarge | c6a.4xlarge | c6a.8xlarge | c6a.large | c6a.metal | c6a.xlarge | c6g.12xlarge | c6g.16xlarge | c6g.2xlarge | c6g.4xlarge | c6g.8xlarge | c6g.large | c6g.medium | c6g.metal | c6g.xlarge | c6gd.12xlarge | c6gd.16xlarge | c6gd.2xlarge | c6gd.4xlarge | c6gd.8xlarge | c6gd.large | c6gd.medium | c6gd.metal | c6gd.xlarge | c6gn.12xlarge | c6gn.16xlarge | c6gn.2xlarge | c6gn.4xlarge | c6gn.8xlarge | c6gn.large | c6gn.medium | c6gn.xlarge | c6i.12xlarge | c6i.16xlarge | c6i.24xlarge | c6i.2xlarge | c6i.32xlarge | c6i.4xlarge | c6i.8xlarge | c6i.large | c6i.metal | c6i.xlarge | c6id.12xlarge | c6id.16xlarge | c6id.24xlarge | c6id.2xlarge | c6id.32xlarge | c6id.4xlarge | c6id.8xlarge | c6id.large | c6id.metal | c6id.xlarge | c6in.12xlarge | c6in.16xlarge | c6in.24xlarge | c6in.2xlarge | c6in.32xlarge | c6in.4xlarge | c6in.8xlarge | c6in.large | c6in.metal | c6in.xlarge | c7a.12xlarge | c7a.16xlarge | c7a.24xlarge | c7a.2xlarge | c7a.32xlarge | c7a.48xlarge | c7a.4xlarge | c7a.8xlarge | c7a.large | c7a.medium | c7a.metal-48xl | c7a.xlarge | c7g.12xlarge | c7g.16xlarge | c7g.2xlarge | c7g.4xlarge | c7g.8xlarge | c7g.large | c7g.medium | c7g.metal | c7g.xlarge | c7gd.12xlarge | c7gd.16xlarge | c7gd.2xlarge | c7gd.4xlarge | c7gd.8xlarge | c7gd.large | c7gd.medium | c7gd.xlarge | c7gn.12xlarge | c7gn.16xlarge | c7gn.2xlarge | c7gn.4xlarge | c7gn.8xlarge | c7gn.large | c7gn.medium | c7gn.xlarge | c7i.12xlarge | c7i.16xlarge | c7i.24xlarge | c7i.2xlarge | c7i.48xlarge | c7i.4xlarge | c7i.8xlarge | c7i.large | c7i.metal-24xl | c7i.metal-48xl | c7i.xlarge | cc1.4xlarge | cc2.8xlarge | cg1.4xlarge | cr1.8xlarge | d2.2xlarge | d2.4xlarge | d2.8xlarge | d2.xlarge | d3.2xlarge | d3.4xlarge | d3.8xlarge | d3.xlarge | d3en.12xlarge | d3en.2xlarge | d3en.4xlarge | d3en.6xlarge | d3en.8xlarge | d3en.xlarge | dl1.24xlarge | f1.16xlarge | f1.2xlarge | f1.4xlarge | g2.2xlarge | g2.8xlarge | g3.16xlarge | g3.4xlarge | g3.8xlarge | g3s.xlarge | g4ad.16xlarge | g4ad.2xlarge | g4ad.4xlarge | g4ad.8xlarge | g4ad.xlarge | g4dn.12xlarge | g4dn.16xlarge | g4dn.2xlarge | g4dn.4xlarge | g4dn.8xlarge | g4dn.metal | g4dn.xlarge | g5.12xlarge | g5.16xlarge | g5.24xlarge | g5.2xlarge | g5.48xlarge | g5.4xlarge | g5.8xlarge | g5.xlarge | g5g.16xlarge | g5g.2xlarge | g5g.4xlarge | g5g.8xlarge | g5g.metal | g5g.xlarge | h1.16xlarge | h1.2xlarge | h1.4xlarge | h1.8xlarge | hi1.4xlarge | hpc6a.48xlarge | hpc6id.32xlarge | hpc7a.12xlarge | hpc7a.24xlarge | hpc7a.48xlarge | hpc7a.96xlarge | hpc7g.16xlarge | hpc7g.4xlarge | hpc7g.8xlarge | hs1.8xlarge | i2.2xlarge | i2.4xlarge | i2.8xlarge | i2.xlarge | i3.16xlarge | i3.2xlarge | i3.4xlarge | i3.8xlarge | i3.large | i3.metal | i3.xlarge | i3en.12xlarge | i3en.24xlarge | i3en.2xlarge | i3en.3xlarge | i3en.6xlarge | i3en.large | i3en.metal | i3en.xlarge | i4g.16xlarge | i4g.2xlarge | i4g.4xlarge | i4g.8xlarge | i4g.large | i4g.xlarge | i4i.12xlarge | i4i.16xlarge | i4i.24xlarge | i4i.2xlarge | i4i.32xlarge | i4i.4xlarge | i4i.8xlarge | i4i.large | i4i.metal | i4i.xlarge | im4gn.16xlarge | im4gn.2xlarge | im4gn.4xlarge | im4gn.8xlarge | im4gn.large | im4gn.xlarge | inf1.24xlarge | inf1.2xlarge | inf1.6xlarge | inf1.xlarge | inf2.24xlarge | inf2.48xlarge | inf2.8xlarge | inf2.xlarge | is4gen.2xlarge | is4gen.4xlarge | is4gen.8xlarge | is4gen.large | is4gen.medium | is4gen.xlarge | m1.large | m1.medium | m1.small | m1.xlarge | m2.2xlarge | m2.4xlarge | m2.xlarge | m3.2xlarge | m3.large | m3.medium | m3.xlarge | m4.10xlarge | m4.16xlarge | m4.2xlarge | m4.4xlarge | m4.large | m4.xlarge | m5.12xlarge | m5.16xlarge | m5.24xlarge | m5.2xlarge | m5.4xlarge | m5.8xlarge | m5.large | m5.metal | m5.xlarge | m5a.12xlarge | m5a.16xlarge | m5a.24xlarge | m5a.2xlarge | m5a.4xlarge | m5a.8xlarge | m5a.large | m5a.xlarge | m5ad.12xlarge | m5ad.16xlarge | m5ad.24xlarge | m5ad.2xlarge | m5ad.4xlarge | m5ad.8xlarge | m5ad.large | m5ad.xlarge | m5d.12xlarge | m5d.16xlarge | m5d.24xlarge | m5d.2xlarge | m5d.4xlarge | m5d.8xlarge | m5d.large | m5d.metal | m5d.xlarge | m5dn.12xlarge | m5dn.16xlarge | m5dn.24xlarge | m5dn.2xlarge | m5dn.4xlarge | m5dn.8xlarge | m5dn.large | m5dn.metal | m5dn.xlarge | m5n.12xlarge | m5n.16xlarge | m5n.24xlarge | m5n.2xlarge | m5n.4xlarge | m5n.8xlarge | m5n.large | m5n.metal | m5n.xlarge | m5zn.12xlarge | m5zn.2xlarge | m5zn.3xlarge | m5zn.6xlarge | m5zn.large | m5zn.metal | m5zn.xlarge | m6a.12xlarge | m6a.16xlarge | m6a.24xlarge | m6a.2xlarge | m6a.32xlarge | m6a.48xlarge | m6a.4xlarge | m6a.8xlarge | m6a.large | m6a.metal | m6a.xlarge | m6g.12xlarge | m6g.16xlarge | m6g.2xlarge | m6g.4xlarge | m6g.8xlarge | m6g.large | m6g.medium | m6g.metal | m6g.xlarge | m6gd.12xlarge | m6gd.16xlarge | m6gd.2xlarge | m6gd.4xlarge | m6gd.8xlarge | m6gd.large | m6gd.medium | m6gd.metal | m6gd.xlarge | m6i.12xlarge | m6i.16xlarge | m6i.24xlarge | m6i.2xlarge | m6i.32xlarge | m6i.4xlarge | m6i.8xlarge | m6i.large | m6i.metal | m6i.xlarge | m6id.12xlarge | m6id.16xlarge | m6id.24xlarge | m6id.2xlarge | m6id.32xlarge | m6id.4xlarge | m6id.8xlarge | m6id.large | m6id.metal | m6id.xlarge | m6idn.12xlarge | m6idn.16xlarge | m6idn.24xlarge | m6idn.2xlarge | m6idn.32xlarge | m6idn.4xlarge | m6idn.8xlarge | m6idn.large | m6idn.metal | m6idn.xlarge | m6in.12xlarge | m6in.16xlarge | m6in.24xlarge | m6in.2xlarge | m6in.32xlarge | m6in.4xlarge | m6in.8xlarge | m6in.large | m6in.metal | m6in.xlarge | m7a.12xlarge | m7a.16xlarge | m7a.24xlarge | m7a.2xlarge | m7a.32xlarge | m7a.48xlarge | m7a.4xlarge | m7a.8xlarge | m7a.large | m7a.medium | m7a.metal-48xl | m7a.xlarge | m7g.12xlarge | m7g.16xlarge | m7g.2xlarge | m7g.4xlarge | m7g.8xlarge | m7g.large | m7g.medium | m7g.metal | m7g.xlarge | m7gd.12xlarge | m7gd.16xlarge | m7gd.2xlarge | m7gd.4xlarge | m7gd.8xlarge | m7gd.large | m7gd.medium | m7gd.xlarge | m7i-flex.2xlarge | m7i-flex.4xlarge | m7i-flex.8xlarge | m7i-flex.large | m7i-flex.xlarge | m7i.12xlarge | m7i.16xlarge | m7i.24xlarge | m7i.2xlarge | m7i.48xlarge | m7i.4xlarge | m7i.8xlarge | m7i.large | m7i.metal-24xl | m7i.metal-48xl | m7i.xlarge | mac1.metal | mac2-m2.metal | mac2-m2pro.metal | mac2.metal | p2.16xlarge | p2.8xlarge | p2.xlarge | p3.16xlarge | p3.2xlarge | p3.8xlarge | p3dn.24xlarge | p4d.24xlarge | p4de.24xlarge | p5.48xlarge | r3.2xlarge | r3.4xlarge | r3.8xlarge | r3.large | r3.xlarge | r4.16xlarge | r4.2xlarge | r4.4xlarge | r4.8xlarge | r4.large | r4.xlarge | r5.12xlarge | r5.16xlarge | r5.24xlarge | r5.2xlarge | r5.4xlarge | r5.8xlarge | r5.large | r5.metal | r5.xlarge | r5a.12xlarge | r5a.16xlarge | r5a.24xlarge | r5a.2xlarge | r5a.4xlarge | r5a.8xlarge | r5a.large | r5a.xlarge | r5ad.12xlarge | r5ad.16xlarge | r5ad.24xlarge | r5ad.2xlarge | r5ad.4xlarge | r5ad.8xlarge | r5ad.large | r5ad.xlarge | r5b.12xlarge | r5b.16xlarge | r5b.24xlarge | r5b.2xlarge | r5b.4xlarge | r5b.8xlarge | r5b.large | r5b.metal | r5b.xlarge | r5d.12xlarge | r5d.16xlarge | r5d.24xlarge | r5d.2xlarge | r5d.4xlarge | r5d.8xlarge | r5d.large | r5d.metal | r5d.xlarge | r5dn.12xlarge | r5dn.16xlarge | r5dn.24xlarge | r5dn.2xlarge | r5dn.4xlarge | r5dn.8xlarge | r5dn.large | r5dn.metal | r5dn.xlarge | r5n.12xlarge | r5n.16xlarge | r5n.24xlarge | r5n.2xlarge | r5n.4xlarge | r5n.8xlarge | r5n.large | r5n.metal | r5n.xlarge | r6a.12xlarge | r6a.16xlarge | r6a.24xlarge | r6a.2xlarge | r6a.32xlarge | r6a.48xlarge | r6a.4xlarge | r6a.8xlarge | r6a.large | r6a.metal | r6a.xlarge | r6g.12xlarge | r6g.16xlarge | r6g.2xlarge | r6g.4xlarge | r6g.8xlarge | r6g.large | r6g.medium | r6g.metal | r6g.xlarge | r6gd.12xlarge | r6gd.16xlarge | r6gd.2xlarge | r6gd.4xlarge | r6gd.8xlarge | r6gd.large | r6gd.medium | r6gd.metal | r6gd.xlarge | r6i.12xlarge | r6i.16xlarge | r6i.24xlarge | r6i.2xlarge | r6i.32xlarge | r6i.4xlarge | r6i.8xlarge | r6i.large | r6i.metal | r6i.xlarge | r6id.12xlarge | r6id.16xlarge | r6id.24xlarge | r6id.2xlarge | r6id.32xlarge | r6id.4xlarge | r6id.8xlarge | r6id.large | r6id.metal | r6id.xlarge | r6idn.12xlarge | r6idn.16xlarge | r6idn.24xlarge | r6idn.2xlarge | r6idn.32xlarge | r6idn.4xlarge | r6idn.8xlarge | r6idn.large | r6idn.metal | r6idn.xlarge | r6in.12xlarge | r6in.16xlarge | r6in.24xlarge | r6in.2xlarge | r6in.32xlarge | r6in.4xlarge | r6in.8xlarge | r6in.large | r6in.metal | r6in.xlarge | r7a.12xlarge | r7a.16xlarge | r7a.24xlarge | r7a.2xlarge | r7a.32xlarge | r7a.48xlarge | r7a.4xlarge | r7a.8xlarge | r7a.large | r7a.medium | r7a.metal-48xl | r7a.xlarge | r7g.12xlarge | r7g.16xlarge | r7g.2xlarge | r7g.4xlarge | r7g.8xlarge | r7g.large | r7g.medium | r7g.metal | r7g.xlarge | r7gd.12xlarge | r7gd.16xlarge | r7gd.2xlarge | r7gd.4xlarge | r7gd.8xlarge | r7gd.large | r7gd.medium | r7gd.xlarge | r7i.12xlarge | r7i.16xlarge | r7i.24xlarge | r7i.2xlarge | r7i.48xlarge | r7i.4xlarge | r7i.8xlarge | r7i.large | r7i.metal-24xl | r7i.metal-48xl | r7i.xlarge | r7iz.12xlarge | r7iz.16xlarge | r7iz.2xlarge | r7iz.32xlarge | r7iz.4xlarge | r7iz.8xlarge | r7iz.large | r7iz.xlarge | t1.micro | t2.2xlarge | t2.large | t2.medium | t2.micro | t2.nano | t2.small | t2.xlarge | t3.2xlarge | t3.large | t3.medium | t3.micro | t3.nano | t3.small | t3.xlarge | t3a.2xlarge | t3a.large | t3a.medium | t3a.micro | t3a.nano | t3a.small | t3a.xlarge | t4g.2xlarge | t4g.large | t4g.medium | t4g.micro | t4g.nano | t4g.small | t4g.xlarge | trn1.2xlarge | trn1.32xlarge | trn1n.32xlarge | u-12tb1.112xlarge | u-12tb1.metal | u-18tb1.112xlarge | u-18tb1.metal | u-24tb1.112xlarge | u-24tb1.metal | u-3tb1.56xlarge | u-6tb1.112xlarge | u-6tb1.56xlarge | u-6tb1.metal | u-9tb1.112xlarge | u-9tb1.metal | vt1.24xlarge | vt1.3xlarge | vt1.6xlarge | x1.16xlarge | x1.32xlarge | x1e.16xlarge | x1e.2xlarge | x1e.32xlarge | x1e.4xlarge | x1e.8xlarge | x1e.xlarge | x2gd.12xlarge | x2gd.16xlarge | x2gd.2xlarge | x2gd.4xlarge | x2gd.8xlarge | x2gd.large | x2gd.medium | x2gd.metal | x2gd.xlarge | x2idn.16xlarge | x2idn.24xlarge | x2idn.32xlarge | x2idn.metal | x2iedn.16xlarge | x2iedn.24xlarge | x2iedn.2xlarge | x2iedn.32xlarge | x2iedn.4xlarge | x2iedn.8xlarge | x2iedn.metal | x2iedn.xlarge | x2iezn.12xlarge | x2iezn.2xlarge | x2iezn.4xlarge | x2iezn.6xlarge | x2iezn.8xlarge | x2iezn.metal | z1d.12xlarge | z1d.2xlarge | z1d.3xlarge | z1d.6xlarge | z1d.large | z1d.metal | z1d.xlarge

The number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. You cannot specify this option and the option to assign specific IPv6 addresses in the same request. You can specify this option if you've specified a minimum number of instances to launch.

You cannot specify this option and the network interfaces option in the same request.

Type : Integer

The IPv6 addresses from the range of the subnet to associate with the primary network interface. You cannot specify this option and the option to assign a number of IPv6 addresses in the same request. You cannot specify this option if you've specified a minimum number of instances to launch.

Type : Array of InstanceIpv6Address

The ID of the kernel.

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB in the Amazon EC2 User Guide .

The name of the key pair. You can create a key pair using CreateKeyPair or ImportKeyPair .

If you do not specify a key pair, you can't connect to the instance unless you choose an AMI that is configured to allow users another way to log in.

The launch template to use to launch the instances. Any parameters that you specify in the AWS CloudFormation template override the same parameters in the launch template. You can specify either the name or ID of a launch template, but not both.

Type : LaunchTemplateSpecification

The license configurations.

Type : Array of LicenseSpecification

Specifies whether detailed monitoring is enabled for the instance. Specify true to enable detailed monitoring. Otherwise, basic monitoring is enabled. For more information about detailed monitoring, see Enable or turn off detailed monitoring for your instances in the Amazon EC2 User Guide .

The network interfaces to associate with the instance.

If you use this property to point to a network interface, you must terminate the original interface before attaching a new one to allow the update of the instance to succeed.

If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the DependsOn Attribute to declare a dependency on the VPC-gateway attachment.

Type : Array of NetworkInterface

The name of an existing placement group that you want to launch the instance into (cluster | partition | spread).

The options for the instance hostname.

Type : PrivateDnsNameOptions

The primary IPv4 address. You must specify a value from the IPv4 address range of the subnet.

Only one private IP address can be designated as primary. You can't specify this option if you've specified the option to designate a private IP address as the primary IP address in a network interface specification. You cannot specify this option if you're launching more than one instance in the request.

If you make an update to an instance that requires replacement, you must assign a new private IP address. During a replacement, AWS CloudFormation creates a new instance but doesn't delete the old instance until the stack has successfully updated. If the stack update fails, AWS CloudFormation uses the old instance to roll back the stack to the previous working state. The old and new instances cannot have the same private IP address.

Indicates whether to assign the tags from the instance to all of the volumes attached to the instance at launch. If you specify true and you assign tags to the instance, those tags are automatically assigned to all of the volumes that you attach to the instance at launch. If you specify false , those tags are not assigned to the attached volumes.

The ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the kernel requirements for information about whether you need to specify a RAM disk. To find kernel requirements, go to the AWS Resource Center and search for the kernel ID.

The IDs of the security groups. You can specify the IDs of existing security groups and references to resources created by the stack template.

If you specify a network interface, you must specify any security groups as part of the network interface.

Type : Array of String

[Default VPC] The names of the security groups. For a nondefault VPC, you must use security group IDs instead.

You cannot specify this option and the network interfaces option in the same request. The list can contain both the name of existing Amazon EC2 security groups or references to AWS::EC2::SecurityGroup resources created in the template.

Default: Amazon EC2 uses the default security group.

Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives. If the value is true , source/destination checks are enabled; otherwise, they are disabled. The default value is true . You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls.

The SSM document and parameter values in AWS Systems Manager to associate with this instance. To use this property, you must specify an IAM instance profile role for the instance. For more information, see Create an IAM instance profile for Systems Manager in the AWS Systems Manager User Guide .

You can currently associate only one document with an instance.

Type : Array of SsmAssociation

The ID of the subnet to launch the instance into.

If you specify a network interface, you must specify any subnets as part of the network interface.

The tags to add to the instance. These tags are not applied to the EBS volumes, such as the root volume, unless PropagateTagsToVolumeOnCreation is true .

Type : Array of Tag

The tenancy of the instance. An instance with a tenancy of dedicated runs on single-tenant hardware.

Allowed values : dedicated | default | host

The user data script to make available to the instance. User data is limited to 16 KB. You must provide base64-encoded text. For more information, see Fn::Base64 .

User data runs only at instance launch. For more information, see Run commands on your Linux instance at launch and Run commands on your Windows instance at launch .

The volumes to attach to the instance.

Type : Array of Volume

Return values

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the instance ID. For example: i-1234567890abcdef0 .

For more information about using the Ref function, see Ref .

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt .

The Availability Zone where the specified instance is launched. For example: us-east-1b .

You can retrieve a list of all Availability Zones for a Region by using the Fn::GetAZs intrinsic function.

The ID of the instance.

The private DNS name of the specified instance. For example: ip-10-24-34-0.ec2.internal .

The private IP address of the specified instance. For example: 10.24.34.0 .

The public DNS name of the specified instance. For example: ec2-107-20-50-45.compute-1.amazonaws.com .

The public IP address of the specified instance. For example: 192.0.2.0 .

EC2 instance with an EBS block device mapping

The following example creates an EC2 instance with a block device mapping with an entry that specifies an io1 volume with a size of 20 GB and an entry that uses NoDevice to override a device specified in the AMI block device mapping.

Automatically assign a public IP address

You can associate a public IP address with a network interface only if it is the primary network interface (the device index is 0) and if you are creating a new network interface, not attaching an existing network interface.

RunInstances in the Amazon EC2 API Reference

Amazon EC2 instances in the Amazon EC2 User Guide

Warning

To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.

AWS re:Post

How can I change or retain my private IP or public IP address when I do an Amazon EC2 restore in AWS Backup?

During an Amazon Elastic Compute Cloud (Amazon EC2) restore in AWS Backup, I want to change or retain my private or public IP address.

Short description

When you launch an EC2 instance, a private IP address is assigned. A public IP address is also automatically assigned to the instance from the EC2-Classic public IPv4 address pool. Use the Amazon EC2 console or AWS Command Line Interface (AWS CLI) to retain or change the original IP address on a restored Amazon EC2 instance.

  • The auto-assigned public IP address that's associated with the instance changes every time the instance is stopped and started.
  • When an EC2 instance is restored, the private IP address is assigned from the subnet.
  • A newly restored instance doesn't retain the original public IP address. However, you can modify the metadata to use the original IP address.
  • An Elastic IP address is a static IP address that can associate or disassociate from the instance. It can't change or move to the EC2-Classic public IPv4 address pool.

Use the Amazon EC2 console to reassociate your Elastic IP address to the restored EC2 instance

To reassociate the original Elastic IP address to the restored instance, you must associate an Elastic IP address with the instance . The Elastic IP address is then maintained after you stop and start your instance.

Use the AWS CLI to reassociate your Elastic IP address to the restored EC2 instance

Run the following associate-address AWS CLI command:

Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent AWS CLI version .

Retain a private IP address to the restored EC2 instance

To retain a private IP address before or during the restore, change the primary private IP address in the metadata output.

Complete the following steps:

1.    Run the get-recovery-point-restore-metadata AWS CLI command:

You receive a metadata output similar to the following one:

2.    Edit the metadata output to retain the original PrivateIpaddress , or change the Primary PrivateIpaddress to a different PrivateIpaddress in the NetworkInterfaces metadata field. The following example output is edited to retain the original PrivateIpaddress :

3.    Save the edited metadata as a .json file. Then, run the following start-restore-job AWS CLI command pointing to the edited metadata file to restore the instance with the private IP address:

Related information

Restoring an Amazon EC2 instance

Amazon EC2 instance IP addressing

AWS OFFICIAL

Editing the serialized part of the metadata wasn't straightforward so I come up with this command:

What this command does:

  • extracts RestoreMetadata
  • removes from it the fields SecurityGroupIds and SubnetId
  • then deserialize and replaces the content of NetworkInterfaces removing NetworkInterfaceId , SecondaryPrivateIpAddressCount , AssociatePublicIpAddress and PrivateIpAddress
  • serializes NetworkInterfaces and creates the json file for the restore job:

YMMV: for example this might not work if the primary ENI has two private addresses.

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile picture

Relevant content

  • Retain private IP when restoring EC2 instance from AWS Backup or Snapshot Accepted Answer rePost-User-5211131 lg ... asked 8 months ago lg ...
  • How can I get a non-Elastic, public IP for an EC2 instance that has only a private IP? Accepted Answer waltforbes lg ... asked a year ago lg ...
  • Private IP address change, effect(s)? markwilhelm lg ... asked 3 years ago lg ...
  • EC2 Private IP Address Across Local Zones nmarti16 lg ... asked a year ago lg ...

profile picture

CloudKatha

How to Assign Elastic IP address to your EC2 Instance in AWS

How to Assign Elastic IP address to your EC2 Instance in AWS

Dear Reader, hope you are doing great today. In this blog post you are going to learn about elastic IP and how you can assign an elastic IP to your EC2 Instance.

One of the biggest benefits of compute capacity in cloud such as EC2 is to be able to start, stop, hibernate or terminate your instance within a matter of seconds.

However, there is a downside as well. If you stop your EC2 instance and start it again, the IP address of your instance changes. That means your instance is no longer accessible using your old IP address.

We will learn how we can solve this problem using Elastic IP addresses.

By the end of this tutorial you should be able to know-

  • What is Elastic IP?

What Problem Does it solve?

  • How to Release an Elastic IP address from EC2 Instance

So let’s get started.

What is an Elastic IP?

An Elastic IP is a pubic IP address that you can allocate to your AWS account. Once allocated, you can associate this elastic IP to any of your EC2 instance, disassociate from one instance and re-associate to another.

That means it’s a reserved public IP address that you can assign to your EC2 instance. We will learn it’s significance in next section.

Let’s know a bit about public IP address.

What is a public IP?

A Public IP address is an IP address that can be accessed directly from internet. If your EC2 instance has public IP that means your instance is reachable over internet or it can communicate with internet.

Whenever you are trying to access your EC2 instance outside of your VPC, you need to use your instance’s public IP. As private IP’s are only accessible from the VPC.

That means an elastic IP is nothing but a static public IP using which you can always connect/access your instance even if it stops and starts or you fail over to a different instance.

When you launch your EC2 instance in a default VPC, your instance receives a public IP at launch. You can use that to connect to your instance.

But the problem is, every time you stop your EC2 instance and start it again, public IP of your instance changes.

Now imagine if you are hosting your application on EC2 and the public IP changes. What is gonna happen?

Well, it’s simple !!!!

Your application becomes inaccessible.

You might think that you will use the new IP address instead. Well that will work of course. But what if you are using a custom domain name where you have specified the IP address of the instance. It is almost impossible and impractical to update the A record manually each time IP address changes.

What’s the solution then?

Well one of the simplest solution is to attach an Elastic IP to your instance. Now even if your system stops , starts or hibernate, your instance has elastic IP attached to it. Even if your instance got terminated somehow, you can launch a new instance and attach the same elastic IP to new instance. By doing this, at route 53 level you wont have to touch and no body will know that behind the scene you failed over from one instance to another.

Now that’s good.

Note: Please know that this is one possible solution however it is recommended to use a load balancer which provides singe entry point to your application using a DNS.

Prerequisite: Launch an EC2 Instance in AWS Step by step

Allocate an Elastic IP

Assign the allocated ip to your instance.

  • Login to  AWS Management Console  and open EC2 service

You can either go to Services -> Compute -> EC2

or type EC2 in the search bar and hit enter. Once you see EC2 option click on that.

How to Assign Elastic IP address to your EC2 Instance in AWS

This will lead you to EC2 dashboard.

2. Scroll down the left navigational menu and Click Elastic IPs from Network and Security Section

how to assign public ip for ec2 instance

3. Click on Allocate Elastic IP address as shown in above screenshot

Keep everything default if you want to use an IP from amazons pool and click Allocate

how to assign public ip for ec2 instance

Once you click Allocate , your static public IP or Elastic IP is allocated successfully and you see similar success response like below

How to Assign Elastic IP address to your EC2 Instance in AWS

By this time we have allocated an Elastic IP in our account and we also have an EC2 instance running. So lets associate the Elastic IP to our instance.

Select the newly created Elastic IP, Click Actions and choose Associate Elastic IP address

how to assign public ip for ec2 instance

Select Resource Type as Instance and choose your instance from the instance field(All your running instances will be shown here)

how to assign public ip for ec2 instance

After You have chosen your instance, click Associate

And there you go !!!

The Elastic IP is now associated with your instance and you get to see success message like below

How to Assign Elastic IP address to your EC2 Instance in AWS

To verify that, stop and start your instance and this time you will notice that Public IP will remain same across stops and starts.

You will also see that Elastic IP is your public IP now. As you can see in the below screenshot, public IP and elastic IP field has got same value 🙂

How to Assign Elastic IP address to your EC2 Instance in AWS

Release the Elastic IP from your Account

Make sure to release the Elastic IP when you don’t need it so that you don’t get billed for it.

If the Elastic IP is still in use, you need to disassociate the IP from instance in order to release it. However, if you have already terminated your instance and Elastic IP is unused you can release the Elastic IP straightway.

Select your Elastic IP, choose Action and then Release Elastic IP addresses

how to assign public ip for ec2 instance

On review popup screen, click Release and your Elastic IP is successfully released.

how to assign public ip for ec2 instance

In this post we learnt –

  • What is Elastic IP Address and it’s Significance
  • To allocate an Elastic IP Address
  • Associate it with an EC2 instance
  • How to release an Elastic IP Address

I hope this post was helpful to you. Feel free to let us know in comment in case you face any issue.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

Meanwhile you can also –

  •   Instagram
  • Share this post with your friends

Suggested Read:

  • Create an EC2 instance in an existing subnet using CloudFormation
  • How to Install Apache Web Server on AWS EC2
  • Understand IAM PassRole to Secure your AWS Infrastructure
  • EC2 Instance Purchasing Options: All You Need to Know
  • Use EC2 User Data Script to Bootstrap Your Instance
  • Attach an IAM Role to an EC2 Instance using CloudFormation

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)

2 thoughts on “ How to Assign Elastic IP address to your EC2 Instance in AWS ”

  • Pingback: How to Associate Elastic IP with EC2 Instance using CloudFormation - CloudKatha
  • Pingback: How to Attach Elastic IP to EC2 Instance using Terraform - CloudKatha

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Notify me of follow-up comments by email.

Notify me of new posts by email.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Assigning a public ip to an ec2 in cloudformation?

In the vpc I am using on aws ec2's do not get a public ip address by default. I am trying to add one manually after referencing this and this bit of documentation.

Currently my cloudformation template includes

There is a lot omitted, but this is everything relevant to adding an ip.

My problem is that the documentation says that only network interfaces with a DeviceIndex of eth0 can have a public ip address, but using eth0 results in an error saying

But if I set the device id to 0 I will get

But if I remove the NetworkInterfaceId and add a subnet id as required by the documentation I get

At this point I have no idea what I should do. According to the documentation my original approach seems correct. Has anyone done this before and can point out what I'm doing wrong?

  • amazon-web-services
  • amazon-cloudformation

Colin Murphy's user avatar

This is what works for me:

Set a private IP as primary IP address in "AWS::EC2::Instance" resource:

Note that the reference to "InternalIPAddress" above is a parameter to pass what internal IP the machine should have. I don't think it's necessary, as without it, the instance will pick up an IP through dhcp.

Then later in the template, add a resource of type "AWS::EC2::EIP":

You can get the External IP with {"Ref" : "EIPExternalIP"}

Edwin's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged amazon-ec2 amazon-web-services amazon-cloudformation ..

  • The Overflow Blog
  • Are remote workers more productive? That’s the wrong question.
  • Featured on Meta
  • Update: New Colors Launched
  • We're rolling back the changes to the Acceptable Use Policy (AUP)

Hot Network Questions

  • Player charmed by Orb of Dragonkind: what can be done?
  • Short story about alien invaders encountering prairie dogs
  • What's wrong with this picture? Impossible circles.
  • I believe this may be a scam, But I just can't see how it would work
  • Haiti to Saint Kitts and Nevis without transiting in the US
  • Are all transactions, whether SegWit or non-SegWit, part of the commitment in a coinbase transaction?
  • Acceptable PCB Practice
  • Digits of Pi in colored spiral
  • When is Animate Objects more effective than Fireball?
  • Do editors pretend that someone asked for you to review to make acceptance of review requests more likely?
  • What is the effect of wind on altimiter reading?
  • Could Megaflora Sustain Permanent Settlements?
  • 90 minute youth activity, what to do?
  • 15 year old crossing the Germany/Netherlands border - do I need parental letter?
  • Feline rider's position: reclining, seated or Prone?
  • What makes small-scale private star-harvesting profitable?
  • The Emotional Complexity in the 'Oppenheimer' Atomic Bomb Test Scene
  • Mathematical papers and the IMRaD-structure: how comparable are they with each other?
  • Etymologically, how did 'outrage' get 're-analyzed'?
  • Why is the Spectrum of an Operator Used as the Domain in Continuous Functional Calculus?
  • "James flicked a peanut at her." — What can "flicked" mean here?
  • Annual bonus changed this year. Is there anything I can do about it?
  • Help reading an 1804 handwritten note about Kamchatka
  • Is one punished for sinful thoughts?

how to assign public ip for ec2 instance

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

web

  • Online Help Center
  • trend-vision-one-aws-agent-install

Install the agent on Amazon EC2 and WorkSpaces

  • launch new Amazon EC2 instances and Amazon WorkSpaces with the agent 'baked in', see Bake the agent into your AMI or WorkSpace bundle .
  • protect Amazon WorkSpaces after already protecting your Amazon EC2 instances, see instead Protect Amazon WorkSpaces if you already added your AWS account .

Add your AWS accounts to Server & Workload Protection

Configure the activation type, deploy agents to your amazon ec2 instances and workspaces, verify that the agent was installed and activated properly, assign a policy.

  • your existing Amazon EC2 instances and Amazon WorkSpaces appear in the Server & Workload Protection console. If no agent is installed on them, they appear with a Status of Unmanaged (Unknown) and a grey dot next to them. If an agent was already installed, they appear with a Status of Managed (Online) and green dot next to them.
  • any new Amazon EC2 instances or Amazon WorkSpaces that you launch through AWS under this AWS account are auto-detected by Server & Workload Protection and displayed in the list of computers.
  • Log in to the Server & Workload Protection console.
  • Click Administration at the top.
  • On the left, click System Settings .
  • In the main pane, make sure the Agents tab is selected.
  • Agent-initiated activation does not require you to open up inbound ports to your Amazon EC2 instances or Amazon WorkSpaces, while manager-initiated activation does.
  • If agent-initiated activation is enabled, manager-initiated activation continues to work.
  • If you selected Allow Agent-Initiated Activation , also select Reactivate cloned Agents , and Enable Reactivate unknown Agents . See Agent settings for more information.
  • Click Save .

bakeami-2.png

What to do next

  • Open ports to your Amazon EC2 instances, as follows: a. Log in to your Amazon Web Services Console . b. Go to EC2 → Network & Security → Security Groups . c. Select the security group that is associated with your EC2 instances, then select Actions > Edit outbound rules . d. Open the necessary ports. See Which ports should be opened? below.
  • Open ports to your Amazon WorkSpaces, as follows: a. Go to the firewall software that is protecting your Amazon WorkSpaces, and open the ports listed above.

Which ports should be opened?

  • agent-to-manager communication requires you to open the outbound TCP port (443 or 80, by default)
  • manager-to-agent communication requires you to open an inbound TCP port (4118).
  • If you enabled Allow Agent-Initiated Activation , you'll need to open the outbound TCP port (443 or 80, by default)
  • If you disabled Allow Agent-Initiated Activation , you'll need to open the inbound TCP port of 4118.
  • Option 1: Use a deployment script to install, activate, and assign a policy Use Option 1 if you need to deploy agents to many Amazon EC2 instances and Amazon WorkSpaces. With this option, you must run a deployment script on the Amazon EC2 instances or Amazon WorkSpaces. The script installs and activates the agent and then assigns a policy. See Use deployment scripts to add and protect computers for details. OR
  • Option 2: Manually install and activate Use Option 2 if you only need to deploy agents to a few EC2 instances and Amazon WorkSpaces. a. Get the agent software, copy it to the Amazon EC2 instance or Amazon WorkSpace, and then install it. For details, see Get the agent software , and Manually install the agent . b. Activate the agent. You can do so on the agent (if agent-initiated activation was enabled) or in Server & Workload Protection . For details, see Activate the agent.
  • Click Computers at the top.
  • On the navigation pane on the left, make sure your Amazon EC2 instance or Amazon WorkSpace appears under Computers > your_AWS_account > your_region . (Look for WorkSpaces in a WorkSpaces sub-node.)
  • In the main pane, make sure your Amazon EC2 instances or Amazon WorkSpaces appear with a Status of Managed (Online) and a green dot next to them.

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

How to create and manage compute instances in Azure AI Studio

  • 1 contributor

Azure AI Studio is currently in public preview. This preview is provided without a service-level agreement, and is not recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews .

In this article, you learn how to create a compute instance in Azure AI Studio. You can create a compute instance in the Azure AI Studio or in the Azure portal.

You need a compute instance to:

  • Use prompt flow in Azure AI Studio.
  • Create an index
  • Open Visual Studio Code (Web) in the Azure AI Studio.

You can use the same compute instance for multiple scenarios and workflows. Note that a compute instance can't be shared. It can only be used by a single assigned user. By default, it will be assigned to the creator and you can change this to a different user in the security step.

Compute instances can run jobs securely in a virtual network environment, without requiring enterprises to open up SSH ports. The job executes in a containerized environment and packages your model dependencies in a Docker container.

Compute instances get the latest VM images at the time of provisioning. Microsoft releases new VM images on a monthly basis. Once a compute instance is deployed, it does not get actively updated. You could query an instance's operating system version. To keep current with the latest software updates and security patches, you could: Recreate a compute instance to get the latest OS image (recommended) or regularly update OS and Python packages on the compute instance to get the latest security patches.

Create a compute instance

To create a compute instance in Azure AI Studio:

Sign in to Azure AI Studio and select your project from the Build page. If you don't have a project already, first create a project.

Under Manage , select Compute instances > + New .

Screenshot of the option to create a new compute instance from the manage page.

Enter a custom name for your compute.

Select your virtual machine type and size and then select Next .

  • Virtual machine type: Choose CPU or GPU. The type can't be changed after creation.
  • Virtual machine size: Supported virtual machine sizes might be restricted in your region. Check the availability list

For more information on configuration details such as CPU and RAM, see Azure Machine Learning pricing and virtual machine sizes .

On the Scheduling page under Auto shut down make sure idle shutdown is enabled by default. You can opt to automatically shut down compute after the instance has been idle for a set amount of time. If you disable auto shutdown costs will continue to accrue even during periods of inactivity. For more information, see Configure idle shutdown .

Screenshot of the option to enable idle shutdown and create a schedule.

The compute can't be idle if you have prompt flow runtime in Running status on the compute. You need to delete any active runtime before the compute instance can be eligible for idle shutdown.

You can update the schedule days and times to meet your needs. You can also add additional schedules. For example, you can create a schedule to start at 9 AM and stop at 6 PM from Monday-Thursday, and a second schedule to start at 9 AM and stop at 4 PM for Friday. You can create a total of four schedules per compute instance.

Screenshot of the available new schedule options.

On the Security page you can optionally configure security settings such as SSH, virtual network, root access, and managed identity for your compute instance. Use this section to:

  • Assign to another user : You can create a compute instance on behalf of another user. Note that a compute instance can't be shared. It can only be used by a single assigned user. By default, it will be assigned to the creator and you can change this to a different user.
  • Assign a managed identity : You can attach system assigned or user assigned managed identities to grant access to resources. The name of the created system managed identity will be in the format /workspace-name/computes/compute-instance-name in your Microsoft Entra ID.
  • Enable SSH access : Enter credentials for an administrator user account that will be created on each compute node. These can be used to SSH to the compute nodes. Note that disabling SSH prevents SSH access from the public internet. But when a private virtual network is used, users can still SSH from within the virtual network.
  • If you're using an Azure Virtual Network, specify the Resource group, Virtual network, and Subnet to create the compute instance inside an Azure Virtual Network. You can also select No public IP to prevent the creation of a public IP address, which requires a private link workspace. You must also satisfy these network requirements for virtual network setup.
  • If you're using a managed virtual network, the compute instance is created inside the managed virtual network. You can also select No public IP to prevent the creation of a public IP address. For more information, see managed compute with a managed network.

On the Applications page you can add custom applications to use on your compute instance, such as RStudio or Posit Workbench. Then select Next .

On the Tags page you can add additional information to categorize the resources you create. Then select Review + Create or Next to review your settings.

Screenshot of the option to review before creating a new compute instance.

After reviewing the settings, select Create to create the compute instance.

Configure idle shutdown

To avoid getting charged for a compute instance that is switched on but inactive, you can configure when to shut down your compute instance due to inactivity.

The setting can be configured during compute instance creation or for existing compute instances.

For new compute instances, you can configure idle shutdown during compute instance creation. For more information, see Create a compute instance earlier in this article.

To configure idle shutdown for existing compute instances follow these steps:

From the top menu, select Manage > Compute instances .

In the list, select the compute instance that you want to configure.

Select Schedule and idle shutdown .

Screenshot of the option to change the idle shutdown schedule for a compute instance.

Update or add to the schedule. You can have a total of four schedules per compute instance. Then select Update to save your changes.

Start or stop a compute instance

You can start or stop a compute instance from the Azure AI Studio.

Select Stop to stop the compute instance. Select Start to start the compute instance. Only stopped compute instances can be started and only started compute instances can be stopped.

Screenshot of the option to start or stop a compute instance.

  • Create and manage prompt flow runtimes

Submit and view feedback for

Additional resources

IMAGES

  1. Assign Public IPs on EC2 Instances

    how to assign public ip for ec2 instance

  2. assigning elastic ip to ec2

    how to assign public ip for ec2 instance

  3. How to Assign Elastic IP address to your EC2 Instance in AWS

    how to assign public ip for ec2 instance

  4. How to Create Elastic IP in AWS and assign to EC2

    how to assign public ip for ec2 instance

  5. How to Assign Multiple IPs Address to one EC2 Instance

    how to assign public ip for ec2 instance

  6. Learn 6

    how to assign public ip for ec2 instance

VIDEO

  1. How to Configure & Assign Static IP Address in Windows 11

  2. How to ssh from one Linux EC2 instance to other Linux EC2 instance

  3. How to assign IP address manually

  4. How to SSH into AWS EC2 Instances

  5. AWS Networking Lab

  6. 🤯🤯 Why EC2 public ip address is so problematic?

COMMENTS

  1. Amazon EC2 instance IP addressing

    You can optionally assign an IPv6 CIDR block to your VPC and assign IPv6 addresses from that block to instances in your subnets. Contents Private IPv4 addresses Public IPv4 addresses Elastic IP addresses (IPv4) IPv6 addresses Work with the IPv4 addresses for your instances Work with the IPv6 addresses for your instances

  2. Assign Public IP (not Elastic IP) after instance launched

    6 Answers Sorted by: 82 The instance that you launched without a public IP will stay without one as it is only assignable when you launch the instance. Even having a subnet with auto assign public IP switched on will not assign a public IP to your instance if, when you launched the instance you chose not to have a public IP.

  3. Associate a static public IP address with your EC2 instance

    To allocate and associate an Elastic IP address with your EC2 Windows or Linux instance or network interface, follow these steps: Allocate an Elastic IP address from either Amazon's pool of public IPv4 addresses or bring your own IP addresses (BYOIP) to your AWS account. Associate the Elastic IP address with an instance or network interface.

  4. Enable auto-assign public IPv4 address in AWS

    Enable auto-assign public IPv4 address option and receive a public IP address from the Amazon pool. If you enable auto-assign public IPv4 address, your instance will automatically receive a public IP address at launch.

  5. Multiple IP addresses

    Learn how to specify multiple IP addresses for your instances on a VPC.

  6. Elastic IP addresses

    When you associate an Elastic IP address with an instance or its primary network interface, the instance's public IPv4 address (if it had one) is released back into Amazon's pool of public IPv4 addresses. You cannot reuse a public IPv4 address, and you cannot convert a public IPv4 address to an Elastic IP address.

  7. Change the primary private IP address of an EC2 instance

    To exchange the IP address of an existing EC2 instance to another instance, complete the following steps: Open the Amazon EC2 console. Choose Network Interfaces, and then choose Actions. Choose Change Termination Behavior, and then clear the box for Delete on termination. Create an AMI of the instance, and then terminate the instance.

  8. How to Add a Static IP to an AWS EC2 Instance

    Step 3: Assigning IP to EC2 Instance. Once the allocation request is successful, assign the static IP to your EC2 instance. On the elastic IP view, select the IP you just allocated and click the Actions dropdown. Select the View details button to reveal the info page on the elastic IP. On this page, click the Associate Elastic IP address button.

  9. How do I associate a static public IP address with my EC2 ...

    Skip directly to the demo: 0:31For more details see the Knowledge Center article with this video: https://repost.aws/knowledge-center/ec2-associate-static-pu...

  10. Assign a custom primary private IP address to an EC2 instance

    Short description. You can associate a custom private IP address to your Amazon EC2 instance while you configure the instance before you launch it. However, the IP address must meet these conditions: Have a valid IPv4 range. Be within the CIDR range of the chosen subnet. Be available. The private IP address must not be tied to any other resource.

  11. How Are Public IP Addresses Assigned to EC2 Instances?

    This option is configured by default to use the subnet setting, which usually means that the instance will be automatically assigned a public IP address unless you tell AWS not to give it one. [Click on image for larger view.] Figure 1: New EC2 instances are assigned a public IP address by default. So with that in mind, take a look at Figure 2.

  12. EC2 assign static public IP address

    1.Firstly, open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. 2.In the navigation pane, choose Network & Security, Elastic IPs. 3.Then, choose Allocate Elastic IP address. 4.For Public IPv4 address pool, choose one of the following:

  13. Connect to your instances without requiring a public IPv4 address using

    EC2 Instance Connect Endpoint allows you to connect to an instance via SSH or RDP without requiring the instance to have a public IPv4 address. How it works. First, you create an EC2 Instance Connect Endpoint in a subnet in your virtual private cloud (VPC). Then, when you want to connect to an instance, you specify the ID of the instance.

  14. AWS::EC2::Instance

    The following example creates an EC2 instance with a block device mapping with an entry that specifies an io1 volume with a size of 20 GB and an entry that uses NoDevice to override a device specified in the AMI block device mapping. ... Automatically assign a public IP address. You can associate a public IP address with a network interface ...

  15. Change or retain private or public IP address for EC2 restore

    A public IP address is also automatically assigned to the instance from the EC2-Classic public IPv4 address pool. Use the Amazon EC2 console or AWS Command Line Interface (AWS CLI) to retain or change the original IP address on a restored Amazon EC2 instance. Note: The auto-assigned public IP address that's associated with the instance changes ...

  16. How to assign a public IP to container running in AWS ECS cluster in

    The cluster is created using: ecs-cli up --cluster-config ecs-service-discovery-stack --ecs-profile ecs-service-discovery-stack --keypair notes-app-key-pair --instance-type t2.micro --capability-iam --force --size 2 There are two services defined, as suggested by the above tutorial.

  17. How to Assign Elastic IP address to your EC2 Instance in AWS

    What Problem Does it solve? When you launch your EC2 instance in a default VPC, your instance receives a public IP at launch. You can use that to connect to your instance. But the problem is, every time you stop your EC2 instance and start it again, public IP of your instance changes.

  18. Can I remove the public IP on my instance without terminating it?

    5 Answers Sorted by: 34 Yes you can remove a public IP address from an instance. This solution applies when your instance was launched in a subnet with the "auto-assign public IP" setting enabled. This makes AWS add a public IP address that seems hard to remove.

  19. Assigning a public ip to an ec2 in cloudformation?

    In the vpc I am using on aws ec2's do not get a public ip address by default. I am trying to add one manually after referencing this and this bit of documentation. ... the instance will pick up an IP through dhcp. Then later in the template, add a resource of type "AWS::EC2::EIP":

  20. Install the agent on Amazon EC2 and WorkSpaces

    Trend Vision One™ Online Help. your existing Amazon EC2 instances and Amazon WorkSpaces appear in the Server & Workload Protection console. If no agent is installed on them, they appear with a Status of Unmanaged (Unknown) and a grey dot next to them. If an agent was already installed, they appear with a Status of Managed (Online) and green dot next to them.

  21. Deploying NodeJS APP on AWS EC2 Instance

    7. Run the application. To run the application put the below command in the command line : #node index.js. 8. Access the application in browser. As you can see in the repository on the GitHub in ...

  22. How to create and manage compute instances in Azure AI Studio

    Sign in to Azure AI Studio and select your project from the Build page. If you don't have a project already, first create a project. Under Manage, select Compute instances > + New. Enter a custom name for your compute. Select your virtual machine type and size and then select Next.