FreeSBC:Cloud:Recovering an Elastic IP address

From TBwiki
Jump to: navigation, search

An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. By using an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. An Elastic IP address is allocated to your AWS account and is yours until you release it. If you have released your Elastic IP address, you might be able to recover it. The following rules apply:

  • You cannot recover an Elastic IP address if it has been allocated to another AWS account, or if it will result in your exceeding your Elastic IP address limit.
  • You cannot recover tags associated with an Elastic IP address.
  • You can recover an Elastic IP address using the Amazon EC2 API or a command-line tool only.

Recovering an Elastic IP address with AWS CLI

You need to install the AWS Command Line Interface (CLI).

1. For the latest version of the AWS CLI, use the following command block:

 $ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 
 unzip awscliv2.zip 
 sudo ./aws/install 

2. Confirm the installation.

aws --version
aws-cli/2.1.12 Python/3.7.3 Linux/3.10.0-1127.18.2.el7.tb.x86_64 exe/x86_64.centos.7 prompt/off 

3. Type aws configure and press enter. Enter the following when prompted:

 AWS Access Key ID [None]: enter the Access Key Id from the credentials.csv file you downloaded in the Create an AWS IAM User part
Note: this should look something like AKIAPWINCOKAO3U4FWTN
AWS Secret Access Key [None]: enter the Secret Access Key from the credentials.csv file you downloaded in the Create an AWS IAM User part
Note: this should look something like 5dqQFBaGuPNf5z7NhFrgou4V5JJNaWPy1XFzBfX3
Default region name [None]: enter us-east-1
Default output format [None]: enter json

AWS CLI 1.png

4. Use the allocate-address AWS CLI command and specify the IP address using the --address parameter as follows.

 aws ec2 allocate-address --domain vpc --address 203.0.113.3 

Recovering an Elastic IP address with PowerShell

You need to install AWS Tools for PowerShell on computers that are running Windows with Windows PowerShell 5.1, or PowerShell Core 6.0 or later.

1. Start a PowerShell session. We recommend that you don't run PowerShell as an administrator with elevated permissions except when required by the task at hand. This is because of the potential security risk and is inconsistent with the principle of least privilege.

2. To install the modularized AWS.Tools package, run the following command.

 PS > Install-Module -Name AWS.Tools.Installer

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure
 you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y 

If you are notified that the repository is "untrusted", it asks you if you want to install anyway. Enter y to allow PowerShell to install the module. To avoid the prompt and install the module without trusting the repository, you can run the command with the -Force parameter.

 PS > Install-Module -Name AWS.Tools.Installer -Force

3. You can now install the module for each AWS service that you want to use by using the Install-AWSToolsModule cmdlet. For example, the following command installs the IAM module. This command also installs any dependent modules that are required for the specified module to work. For example, when you install your first AWS.Tools service module, it also installs AWS.Tools.Common. This is a shared module required by all AWS service modules. It also removes older versions of the modules, and updates other modules to the same newer version.

PS > Install-AWSToolsModule AWS.Tools.EC2,AWS.Tools.S3 -CleanUp
  Confirm
  Are you sure you want to perform this action?
  Performing the operation "Install-AWSToolsModule" on target "AWS Tools version 4.0.0.0".
  [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

  Installing module AWS.Tools.Common version 4.0.0.0
  Installing module AWS.Tools.EC2 version 4.0.0.0
  Installing module AWS.Tools.Glacier version 4.0.0.0
  Installing module AWS.Tools.S3 version 4.0.0.0

  Uninstalling AWS.Tools version 3.3.618.0
  Uninstalling module AWS.Tools.Glacier
  Uninstalling module AWS.Tools.S3
  Uninstalling module AWS.Tools.SimpleNotificationService
  Uninstalling module AWS.Tools.SQS
  Uninstalling module AWS.Tools.Common

4. To add a new profile to the AWS SDK store, run the command Set-AWSCredential. It stores your access key and secret key in your default credentials file under the profile name you specify.

PS > Set-AWSCredential `
                 -AccessKey AKIA0123456787EXAMPLE `
                 -SecretKey wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY `
                 -StoreAs MyNewProfile
  • -AccessKey– The access key ID.
  • -SecretKey– The secret key.
  • -StoreAs– The profile name, which must be unique. To specify the default profile, use the name default.

5. Use the New-EC2Address AWS Tools for Windows PowerShell command and specify the IP address using the -Address parameter as follows.

PS C:\> New-EC2Address -Address 203.0.113.3 -Domain vpc -Region us-east-1
Personal tools