id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
874a8579010d-1
+ G3 instances: ``` [ec2-user ~]$ sudo nvidia-smi -ac 2505,1177 ``` + G4 instances: ``` [ec2-user ~]$ sudo nvidia-smi -ac 5001,1590 ``` + P2 instances: ``` [ec2-user ~]$ sudo nvidia-smi -ac 2505,875 ``` + P3 and P3dn instances: ``` [ec2-user ~]$ sudo nvidia-smi -ac 877,1530 ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/optimize_gpu.md
e5c381f3cbb5-0
To use an EC2 Fleet, you create a request that includes the total target capacity, On\-Demand capacity, Spot capacity, one or more launch specifications for the instances, and the maximum price that you are willing to pay\. The fleet request must include a launch template that defines the information that the fleet needs to launch an instance, such as an AMI, instance type, subnet or Availability Zone, and one or more security groups\. You can specify launch specification overrides for the instance type, subnet, Availability Zone, and maximum price you're willing to pay, and you can assign weighted capacity to each launch specification override\. If your fleet includes Spot Instances, Amazon EC2 can attempt to maintain your fleet target capacity as Spot prices change\. An EC2 Fleet request remains active until it expires or you delete it\. When you delete a fleet, you can specify whether deletion terminates the instances in that fleet\. **Topics** + [EC2 Fleet request states](#EC2-fleet-states) + [EC2 Fleet prerequisites](#ec2-fleet-prerequisites) + [EC2 Fleet health checks](#ec2-fleet-health-checks) + [Generating an EC2 Fleet JSON configuration file](#ec2-fleet-cli-skeleton) + [Creating an EC2 Fleet](#create-ec2-fleet) + [Tagging an EC2 Fleet](#tag-ec2-fleet) + [Monitoring your EC2 Fleet](#monitor-ec2-fleet)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
e5c381f3cbb5-1
+ [Monitoring your EC2 Fleet](#monitor-ec2-fleet) + [Modifying an EC2 Fleet](#modify-ec2-fleet) + [Deleting an EC2 Fleet](#delete-fleet) + [EC2 Fleet example configurations](ec2-fleet-examples.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
8c68fcb2536b-0
An EC2 Fleet request can be in one of the following states: + `submitted` – The EC2 Fleet request is being evaluated and Amazon EC2 is preparing to launch the target number of instances, which can include On\-Demand Instances, Spot Instances, or both\. + `active` – The EC2 Fleet request has been validated and Amazon EC2 is attempting to maintain the target number of running instances\. The request remains in this state until it is modified or deleted\. + `modifying` – The EC2 Fleet request is being modified\. The request remains in this state until the modification is fully processed or the request is deleted\. Only a `maintain` request type can be modified\. This state does not apply to other request types\. + `deleted_running` – The EC2 Fleet request is deleted and does not launch additional instances\. Its existing instances continue to run until they are interrupted or terminated\. The request remains in this state until all instances are interrupted or terminated\. + `deleted_terminating` – The EC2 Fleet request is deleted and its instances are terminating\. The request remains in this state until all instances are terminated\. + `deleted` – The EC2 Fleet is deleted and has no running instances\. The request is deleted two days after its instances are terminated\. The following illustration represents the transitions between the EC2 Fleet request states\. If you exceed your fleet limits, the request is deleted immediately\. ![\[EC2 Fleet request states\]](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/images/EC2_fleet_states.png)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
1978b3674db1-0
To create an EC2 Fleet, the following prerequisites must be in place\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
17fcd47a48c9-0
A launch template includes information about the instances to launch, such as the instance type, Availability Zone, and the maximum price that you are willing to pay\. For more information, see [Launching an instance from a launch template](ec2-launch-templates.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
a2618bf327a2-0
The `AWSServiceRoleForEC2Fleet` role grants the EC2 Fleet permission to request, launch, terminate, and tag instances on your behalf\. Amazon EC2 uses this service\-linked role to complete the following actions: + `ec2:RunInstances` – Launch instances\. + `ec2:RequestSpotInstances` – Request Spot Instances\. + `ec2:TerminateInstances` – Terminate instances\. + `ec2:DescribeImages` – Describe Amazon Machine Images \(AMIs\) for the Spot Instances\. + `ec2:DescribeInstanceStatus` – Describe the status of the Spot Instances\. + `ec2:DescribeSubnets` – Describe the subnets for Spot Instances\. + `ec2:CreateTags` – Add tags to the EC2 Fleet, instances, and volumes\. Ensure that this role exists before you use the AWS CLI or an API to create an EC2 Fleet\. **Note** An `instant` EC2 Fleet does not require this role\. To create the role, use the IAM console as follows\. **To create the AWSServiceRoleForEC2Fleet role for EC2 Fleet** 1. Open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. In the navigation pane, choose **Roles**, and then choose **Create role**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
a2618bf327a2-1
1. In the navigation pane, choose **Roles**, and then choose **Create role**\. 1. For **Select type of trusted entity**, choose **AWS service**\. 1. For **Choose the service that will use this role**, choose **EC2 \- Fleet**, and then choose **Next: Permissions**, **Next: Tags**, and **Next: Review**\. 1. On the **Review** page, choose **Create role**\. If you no longer need to use EC2 Fleet, we recommend that you delete the **AWSServiceRoleForEC2Fleet** role\. After this role is deleted from your account, you can create the role again if you create another fleet\. For more information, see [Using Service\-Linked Roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
c38a5206c232-0
If you specify an [encrypted AMI](AMIEncryption.md) or an [encrypted Amazon EBS snapshot](EBSEncryption.md) in your EC2 Fleet and you use a customer\-managed customer master key \(CMK\) for encryption, you must grant the **AWSServiceRoleForEC2Fleet** role permission to use the CMK so that Amazon EC2 can launch instances on your behalf\. To do this, you must add a grant to the CMK, as shown in the following procedure\. When providing permissions, grants are an alternative to key policies\. For more information, see [Using Grants](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html) and [Using Key Policies in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html) in the *AWS Key Management Service Developer Guide*\. **To grant the AWSServiceRoleForEC2Fleet role permissions to use the CMK**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
c38a5206c232-1
**To grant the AWSServiceRoleForEC2Fleet role permissions to use the CMK** + Use the [create\-grant](https://docs.aws.amazon.com/cli/latest/reference/kms/create-grant.html) command to add a grant to the CMK and to specify the principal \(the **AWSServiceRoleForEC2Fleet** service\-linked role\) that is given permission to perform the operations that the grant permits\. The CMK is specified by the `key-id` parameter and the ARN of the CMK\. The principal is specified by the `grantee-principal` parameter and the ARN of the **AWSServiceRoleForEC2Fleet** service\-linked role\. ``` aws kms create-grant \ --region us-east-1 \ --key-id arn:aws:kms:us-east-1:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab \ --grantee-principal arn:aws:iam::111122223333:role/AWSServiceRoleForEC2Fleet \ --operations "Decrypt" "Encrypt" "GenerateDataKey" "GenerateDataKeyWithoutPlaintext" "CreateGrant" "DescribeKey" "ReEncryptFrom" "ReEncryptTo" ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
3ec47ba77ecb-0
If your IAM users will create or manage an EC2 Fleet, be sure to grant them the required permissions as follows\. **To grant an IAM user permissions for EC2 Fleet** 1. Open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. In the navigation pane, choose **Policies**\. 1. Choose **Create policy**\. 1. On the **Create policy** page, choose the **JSON** tab, replace the text with the following, and choose **Review policy**\. ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:*" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "iam:ListRoles", "iam:PassRole", "iam:ListInstanceProfiles" ], "Resource": "*" } ] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
3ec47ba77ecb-1
], "Resource": "*" } ] } ``` The `ec2:*` grants an IAM user permission to call all Amazon EC2 API actions\. To limit the user to specific Amazon EC2 API actions, specify those actions instead\. An IAM user must have permission to call the `iam:ListRoles` action to enumerate existing IAM roles, the `iam:PassRole` action to specify the EC2 Fleet role, and the `iam:ListInstanceProfiles` action to enumerate existing instance profiles\. \(Optional\) To enable an IAM user to create roles or instance profiles using the IAM console, you must also add the following actions to the policy: + `iam:AddRoleToInstanceProfile` + `iam:AttachRolePolicy` + `iam:CreateInstanceProfile` + `iam:CreateRole` + `iam:GetRole` + `iam:ListPolicies` 1. On the **Review policy** page, enter a policy name and description, and choose **Create policy**\. 1. In the navigation pane, choose **Users** and select the user\. 1. On the **Permissions** tab, choose **Add permissions**\. 1. Choose **Attach existing policies directly**\. Select the policy that you created earlier and choose **Next: Review**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
3ec47ba77ecb-2
1. Choose **Attach existing policies directly**\. Select the policy that you created earlier and choose **Next: Review**\. 1. Choose **Add permissions**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
c22784d6e083-0
EC2 Fleet checks the health status of the instances in the fleet every two minutes\. The health status of an instance is either `healthy` or `unhealthy`\. The fleet determines the health status of an instance using the status checks provided by Amazon EC2\. If the status of either the instance status check or the system status check is `impaired` for three consecutive health checks, the health status of the instance is `unhealthy`\. Otherwise, the health status is `healthy`\. For more information, see [Status checks for your instances](monitoring-system-instance-status-check.md)\. You can configure your EC2 Fleet to replace unhealthy instances\. After enabling health check replacement, an instance is replaced after its health status is reported as `unhealthy`\. The fleet could go below its target capacity for up to a few minutes while an unhealthy instance is being replaced\. **Requirements** + Health check replacement is supported only with EC2 Fleets that maintain a target capacity, not with one\-time fleets\. + You can configure your EC2 Fleet to replace unhealthy instances only when you create it\. + IAM users can use health check replacement only if they have permission to call the `ec2:DescribeInstanceStatus` action\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
49bf29dcac00-0
To create an EC2 Fleet, you need only specify the launch template, total target capacity, and whether the default purchasing option is On\-Demand or Spot\. If you do not specify a parameter, the fleet uses the default value\. To view the full list of fleet configuration parameters, you can generate a JSON file as follows\. **To generate a JSON file with all possible EC2 Fleet parameters using the command line** + Use the [create\-fleet](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-fleet.html) \(AWS CLI\) command and the `--generate-cli-skeleton` parameter to generate an EC2 Fleet JSON file: ``` aws ec2 create-fleet \ --generate-cli-skeleton ``` The following EC2 Fleet parameters are available: ``` { "DryRun": true, "ClientToken": "", "SpotOptions": { "AllocationStrategy": "lowest-price", "InstanceInterruptionBehavior": "hibernate", "InstancePoolsToUseCount": 0, "SingleInstanceType": true, "SingleAvailabilityZone": true, "MaxTotalPrice": 0, "MinTargetCapacity": 0 },
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
49bf29dcac00-1
"MaxTotalPrice": 0, "MinTargetCapacity": 0 }, "OnDemandOptions": { "AllocationStrategy": "prioritized", "SingleInstanceType": true, "SingleAvailabilityZone": true, "MaxTotalPrice": 0, "MinTargetCapacity": 0 }, "ExcessCapacityTerminationPolicy": "termination", "LaunchTemplateConfigs": [ { "LaunchTemplateSpecification": { "LaunchTemplateId": "", "LaunchTemplateName": "", "Version": "" }, "Overrides": [ { "InstanceType": "t2.micro", "MaxPrice": "", "SubnetId": "", "AvailabilityZone": "", "WeightedCapacity": null, "Priority": null, "Placement": { "AvailabilityZone": "", "Affinity": "", "GroupName": "", "PartitionNumber": 0, "HostId": "", "Tenancy": "dedicated",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
49bf29dcac00-2
"PartitionNumber": 0, "HostId": "", "Tenancy": "dedicated", "SpreadDomain": "" } ] } ], "TargetCapacitySpecification": { "TotalTargetCapacity": 0, "OnDemandTargetCapacity": 0, "SpotTargetCapacity": 0, "DefaultTargetCapacityType": "spot" }, "TerminateInstancesWithExpiration": true, "Type": "maintain", "ValidFrom": "1970-01-01T00:00:00", "ValidUntil": "1970-01-01T00:00:00", "ReplaceUnhealthyInstances": true, "TagSpecifications": [ { "ResourceType": "fleet", "Tags": [ { "Key": "", "Value": "" } ] } ] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-0
**Note** Use lowercase for all parameter values; otherwise, you get an error when Amazon EC2 uses the JSON file to launch the EC2 Fleet\. **AllocationStrategy \(for SpotOptions\)** \(Optional\) Indicates how to allocate the Spot Instance target capacity across the Spot Instance pools specified by the EC2 Fleet\. Valid values are `lowest-price`, `diversified`, and `capacity-optimized`\. The default is `lowest-price`\. Specify the allocation strategy that meets your needs\. For more information, see [Allocation strategies for Spot Instances](ec2-fleet-configuration-strategies.md#ec2-fleet-allocation-strategy)\. **InstanceInterruptionBehavior** \(Optional\) The behavior when a Spot Instance is interrupted\. Valid values are `hibernate`, `stop`, and `terminate`\. By default, the Spot service terminates Spot Instances when they are interrupted\. If the fleet type is `maintain`, you can specify that the Spot service hibernates or stops Spot Instances when they are interrupted\. **InstancePoolsToUseCount** The number of Spot pools across which to allocate your target Spot capacity\. Valid only when Spot **AllocationStrategy** is set to `lowest-price`\. EC2 Fleet selects the cheapest Spot pools and evenly allocates your target Spot capacity across the number of Spot pools that you specify\. **SingleInstanceType** Indicates that the fleet uses a single instance type to launch all Spot Instances in the fleet\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-1
**SingleInstanceType** Indicates that the fleet uses a single instance type to launch all Spot Instances in the fleet\. **SingleAvailabilityZone** Indicates that the fleet launches all Spot Instances into a single Availability Zone\. **MaxTotalPrice** The maximum amount per hour for Spot Instances that you're willing to pay\. **MinTargetCapacity** The minimum target capacity for Spot Instances in the fleet\. If the minimum target capacity is not reached, the fleet launches no instances\. **AllocationStrategy \(for OnDemandOptions\)** The order of the launch template overrides to use in fulfilling On\-Demand capacity\. If you specify `lowest-price`, EC2 Fleet uses price to determine the order, launching the lowest price first\. If you specify prioritized, EC2 Fleet uses the priority that you assigned to each launch template override, launching the highest priority first\. If you do not specify a value, EC2 Fleet defaults to `lowest-price`\. **SingleInstanceType** Indicates that the fleet uses a single instance type to launch all On\-Demand Instances in the fleet\. **SingleAvailabilityZone** Indicates that the fleet launches all On\-Demand Instances into a single Availability Zone\. **MaxTotalPrice** The maximum amount per hour for On\-Demand Instances that you're willing to pay\. **MinTargetCapacity**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-2
The maximum amount per hour for On\-Demand Instances that you're willing to pay\. **MinTargetCapacity** The minimum target capacity for On\-Demand Instances in the fleet\. If the minimum target capacity is not reached, the fleet launches no instances\. **ExcessCapacityTerminationPolicy** \(Optional\) Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the EC2 Fleet\. Valid values are `no-termination` and `termination`\. **LaunchTemplateId** The ID of the launch template to use\. You must specify either the launch template ID or launch template name\. The launch template must specify an Amazon Machine Image \(AMI\)\. For information about creating launch templates, see [Launching an instance from a launch template](ec2-launch-templates.md)\. **LaunchTemplateName** The name of the launch template to use\. You must specify either the launch template ID or launch template name\. The launch template must specify an Amazon Machine Image \(AMI\)\. For more information, see [Launching an instance from a launch template](ec2-launch-templates.md)\. **Version**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-3
**Version** The launch template version number, `$Latest`, or `$Default`\. You must specify a value, otherwise the request fails\. If the value is `$Latest`, Amazon EC2 uses the latest version of the launch template\. If the value is `$Default`, Amazon EC2 uses the default version of the launch template\. For more information, see [Managing launch template versions](ec2-launch-templates.md#manage-launch-template-versions)\. **InstanceType** \(Optional\) The instance type\. If entered, this value overrides the launch template\. The instance types must have the minimum hardware specifications that you need \(vCPUs, memory, or storage\)\. **MaxPrice** \(Optional\) The maximum price per unit hour that you are willing to pay for a Spot Instance\. If entered, this value overrides the launch template\. You can use the default maximum price \(the On\-Demand price\) or specify the maximum price that you are willing to pay\. Your Spot Instances are not launched if your maximum price is lower than the Spot price for the instance types that you specified\. **SubnetId** \(Optional\) The ID of the subnet in which to launch the instances\. If entered, this value overrides the launch template\. To create a new VPC, go the Amazon VPC console\. When you are done, return to the JSON file and enter the new subnet ID\. **AvailabilityZone**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-4
**AvailabilityZone** \(Optional\) The Availability Zone in which to launch the instances\. The default is to let AWS choose the zones for your instances\. If you prefer, you can specify specific zones\. If entered, this value overrides the launch template\. Specify one or more Availability Zones\. If you have more than one subnet in a zone, specify the appropriate subnet\. To add subnets, go to the Amazon VPC console\. When you are done, return to the JSON file and enter the new subnet ID\. **WeightedCapacity** \(Optional\) The number of units provided by the specified instance type\. If entered, this value overrides the launch template\. **Priority** The priority for the launch template override\. If **AllocationStrategy** is set to `prioritized`, EC2 Fleet uses priority to determine which launch template override to use first in fulfilling On\-Demand capacity\. The highest priority is launched first\. Valid values are whole numbers starting at `0`\. The lower the number, the higher the priority\. If no number is set, the override has the lowest priority\. **TotalTargetCapacity** The number of instances to launch\. You can choose instances or performance characteristics that are important to your application workload, such as vCPUs, memory, or storage\. If the request type is `maintain`, you can specify a target capacity of 0 and add capacity later\. **OnDemandTargetCapacity**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-5
**OnDemandTargetCapacity** \(Optional\) The number of On\-Demand Instances to launch\. This number must be less than the `TotalTargetCapacity`\. **SpotTargetCapacity** \(Optional\) The number of Spot Instances to launch\. This number must be less than the `TotalTargetCapacity`\. **DefaultTargetCapacityType** If the value for `TotalTargetCapacity` is higher than the combined values for `OnDemandTargetCapacity` and `SpotTargetCapacity`, the difference is launched as the instance purchasing option specified here\. Valid values are `on-demand` or `spot`\. **TerminateInstancesWithExpiration** \(Optional\) By default, Amazon EC2 terminates your instances when the EC2 Fleet request expires\. The default value is `true`\. To keep them running after your request expires, do not enter a value for this parameter\. **Type**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-6
**Type** \(Optional\) Indicates whether the EC2 Fleet submits a synchronous one\-time request for your desired capacity \(`instant`\), or an asynchronous one\-time request for your desired capacity, but with no attempt maintain the capacity or to submit requests in alternative capacity pools if capacity is unavailable \(`request`\), or submits an asynchronous request for your desired capacity and continues to maintain your desired capacity by replenishing interrupted Spot Instances \(`maintain`\)\. Valid values are `instant`, `request`, and `maintain`\. The default value is `maintain`\. For more information, see [EC2 Fleet request types](ec2-fleet-configuration-strategies.md#ec2-fleet-request-type)\. **ValidFrom** \(Optional\) To create a request that is valid only during a specific time period, enter a start date\. **ValidUntil** \(Optional\) To create a request that is valid only during a specific time period, enter an end date\. **ReplaceUnhealthyInstances** \(Optional\) To replace unhealthy instances in an EC2 Fleet that is configured to `maintain` the fleet, enter `true`\. Otherwise, leave this parameter empty\. **TagSpecifications**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
02c6bb74435b-7
**TagSpecifications** \(Optional\) The key\-value pair for tagging the EC2 Fleet request on creation\. The value for `ResourceType` must be `fleet`, otherwise the fleet request fails\. To tag instances at launch, specify the tags in the [launch template](ec2-launch-templates.md#create-launch-template)\. For information about tagging after launch, see [Tagging your resources](Using_Tags.md#tag-resources)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-0
When you create an EC2 Fleet, you must specify a launch template that includes information about the instances to launch, such as the instance type, Availability Zone, and the maximum price you are willing to pay\. You can create an EC2 Fleet that includes multiple launch specifications that override the launch template\. The launch specifications can vary by instance type, Availability Zone, subnet, and maximum price, and can include a different weighted capacity\. When you create an EC2 Fleet, use a JSON file to specify information about the instances to launch\. For more information, see [EC2 Fleet JSON configuration file reference](#ec2-fleet-json-reference)\. EC2 Fleets can only be created using the AWS CLI\. **To create an EC2 Fleet \(AWS CLI\)** + Use the [create\-fleet](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-fleet.html) \(AWS CLI\) command to create an EC2 Fleet\. ``` aws ec2 create-fleet \ --cli-input-json file://file_name.json ``` For example configuration files, see [EC2 Fleet example configurations](ec2-fleet-examples.md)\. The following is example output for a fleet of type `request` or `maintain`\. ``` {
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-1
The following is example output for a fleet of type `request` or `maintain`\. ``` { "FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE" } ``` The following is example output for a fleet of type `instant` that launched the target capacity\. ``` { "FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE", "Errors": [], "Instances": [ { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c5.large", "AvailabilityZone": "us-east-1a" } }, "Lifecycle": "on-demand", "InstanceIds": [ "i-1234567890abcdef0", "i-9876543210abcdef9" ], "InstanceType": "c5.large",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-2
"i-9876543210abcdef9" ], "InstanceType": "c5.large", "Platform": null }, { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c4.large", "AvailabilityZone": "us-east-1a" } }, "Lifecycle": "on-demand", "InstanceIds": [ "i-5678901234abcdef0", "i-5432109876abcdef9" ], "InstanceType": "c4.large", "Platform": null }, ] } ``` The following is example output for a fleet of type `instant` that launched part of the target capacity with errors for instances that were not launched\. ``` { "FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE", "Errors": [
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-3
"Errors": [ { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c4.xlarge", "AvailabilityZone": "us-east-1a", } }, "Lifecycle": "on-demand", "ErrorCode": "InsufficientInstanceCapacity", "ErrorMessage": "", "InstanceType": "c4.xlarge", "Platform": null }, ], "Instances": [ { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c5.large", "AvailabilityZone": "us-east-1a" } }, "Lifecycle": "on-demand", "InstanceIds": [
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-4
} }, "Lifecycle": "on-demand", "InstanceIds": [ "i-1234567890abcdef0", "i-9876543210abcdef9" ], "InstanceType": "c5.large", "Platform": null }, ] } ``` The following is example output for a fleet of type `instant` that launched no instances\. ``` { "FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE", "Errors": [ { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c4.xlarge", "AvailabilityZone": "us-east-1a", } }, "Lifecycle": "on-demand", "ErrorCode": "InsufficientCapacity", "ErrorMessage": "",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
fb32056a2d8e-5
"ErrorCode": "InsufficientCapacity", "ErrorMessage": "", "InstanceType": "c4.xlarge", "Platform": null }, { "LaunchTemplateAndOverrides": { "LaunchTemplateSpecification": { "LaunchTemplateId": "lt-01234a567b8910abcEXAMPLE", "Version": "1" }, "Overrides": { "InstanceType": "c5.large", "AvailabilityZone": "us-east-1a", } }, "Lifecycle": "on-demand", "ErrorCode": "InsufficientCapacity", "ErrorMessage": "", "InstanceType": "c5.large", "Platform": null }, ], "Instances": [] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
20cf08817ece-0
To help categorize and manage your EC2 Fleet requests, you can tag them with custom metadata\. You can assign a tag to an EC2 Fleet request when you create it, or afterward\. When you tag a fleet request, the instances and volumes that are launched by the fleet are not automatically tagged\. You need to explicitly tag the instances and volumes launched by the fleet\. You can choose to assign tags to only the fleet request, or to only the instances launched by the fleet, or to only the volumes attached to the instances launched by the fleet, or to all three\. **Note** For `instant` fleet types, you can tag volumes that are attached to On\-Demand Instances and Spot Instances\. For `request` or `maintain` fleet types, you can only tag volumes that are attached to On\-Demand Instances\. For more information about how tags work, see [Tagging your Amazon EC2 resources](Using_Tags.md)\. **Prerequisite** Grant the IAM user the permission to tag resources\. For more information, see [Example: Tagging resources](ExamplePolicies_EC2.md#iam-example-taggingresources)\. **To grant an IAM user the permission to tag resources** Create a IAM policy that includes the following: + The `ec2:CreateTags` action\. This grants the IAM user permission to create tags\. + The `ec2:CreateFleet` action\. This grants the IAM user permission to create an EC2 Fleet request\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
20cf08817ece-1
+ The `ec2:CreateFleet` action\. This grants the IAM user permission to create an EC2 Fleet request\. + For `Resource`, we recommend that you specify `"*"`\. This allows users to tag all resource types\. ``` { "Version": "2012-10-17", "Statement": [ { "Sid": "TagEC2FleetRequest", "Effect": "Allow", "Action": [ "ec2:CreateTags", "ec2:CreateFleet" ], "Resource": "*" } ``` **Important** We currently do not support resource\-level permissions for the `create-fleet` resource\. If you specify `create-fleet` as a resource, you will get an unauthorized exception when you try to tag the fleet\. The following example illustrates how *not* to set the policy\. ``` { "Effect": "Allow", "Action": [ "ec2:CreateTags", "ec2:CreateFleet" ], "Resource": "arn:aws:ec2:us-east-1:111122223333:create-fleet/*" } ``` **To tag a new EC2 Fleet request**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
20cf08817ece-2
} ``` **To tag a new EC2 Fleet request** To tag an EC2 Fleet request when you create it, specify the key\-value pair in the [JSON file](#ec2-fleet-cli-skeleton) used to create the fleet\. The value for `ResourceType` must be `fleet`\. If you specify another value, the fleet request fails\. **To tag instances and volumes launched by an EC2 Fleet** To tag instances and volumes when they are launched by the fleet, specify the tags in the [launch template](ec2-launch-templates.md#create-launch-template) that is referenced in the EC2 Fleet request\. **Note** You can't tag volumes attached to Spot Instances that are launched by a `request` or `maintain` fleet type\. **To tag an existing EC2 Fleet request, instance, and volume \(AWS CLI\)** Use the [create\-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html) command to tag existing resources\. ``` aws ec2 create-tags \ --resources fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE i-1234567890abcdef0 vol-1234567890EXAMPLE \ --tags Key=purpose,Value=test ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
dfcdd33fcc54-0
The EC2 Fleet launches On\-Demand Instances when there is available capacity, and launches Spot Instances when your maximum price exceeds the Spot price and capacity is available\. The On\-Demand Instances run until you terminate them, and the Spot Instances run until they are interrupted or you terminate them\. The returned list of running instances is refreshed periodically and might be out of date\. **To monitor your EC2 Fleet \(AWS CLI\)** Use the [describe\-fleets](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-fleets.html) command to describe your EC2 Fleets\. ``` aws ec2 describe-fleets ``` The following is example output\. ``` { "Fleets": [ { "Type": "maintain", "FulfilledCapacity": 2.0, "LaunchTemplateConfigs": [ { "LaunchTemplateSpecification": { "Version": "2", "LaunchTemplateId": "lt-07b3bc7625cdab851" } } ], "TerminateInstancesWithExpiration": false, "TargetCapacitySpecification": { "OnDemandTargetCapacity": 0, "SpotTargetCapacity": 2,
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
dfcdd33fcc54-1
"OnDemandTargetCapacity": 0, "SpotTargetCapacity": 2, "TotalTargetCapacity": 2, "DefaultTargetCapacityType": "spot" }, "FulfilledOnDemandCapacity": 0.0, "ActivityStatus": "fulfilled", "FleetId": "fleet-76e13e99-01ef-4bd6-ba9b-9208de883e7f", "ReplaceUnhealthyInstances": false, "SpotOptions": { "InstanceInterruptionBehavior": "terminate", "InstancePoolsToUseCount": 1, "AllocationStrategy": "lowest-price" }, "FleetState": "active", "ExcessCapacityTerminationPolicy": "termination", "CreateTime": "2018-04-10T16:46:03.000Z" } ] } ``` Use the [describe\-fleet\-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-fleet-instances.html) command to describe the instances for the specified EC2 Fleet\. ``` aws ec2 describe-fleet-instances \
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
dfcdd33fcc54-2
``` aws ec2 describe-fleet-instances \ --fleet-id fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE ``` ``` { "ActiveInstances": [ { "InstanceId": "i-09cd595998cb3765e", "InstanceHealth": "healthy", "InstanceType": "m4.large", "SpotInstanceRequestId": "sir-86k84j6p" }, { "InstanceId": "i-09cf95167ca219f17", "InstanceHealth": "healthy", "InstanceType": "m4.large", "SpotInstanceRequestId": "sir-dvxi7fsm" } ], "FleetId": "fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE" } ``` Use the [describe\-fleet\-history](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-fleet-request-history.html) command to describe the history for the specified EC2 Fleet for the specified time\. ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
dfcdd33fcc54-3
``` aws ec2 describe-fleet-history --fleet-request-id fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE --start-time 2018-04-10T00:00:00Z ``` ``` { "HistoryRecords": [], "FleetId": "fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE", "LastEvaluatedTime": "1970-01-01T00:00:00.000Z", "StartTime": "2018-04-09T23:53:20.000Z" } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
f3218eab695c-0
You can modify an EC2 Fleet that is in the `submitted` or `active` state\. When you modify a fleet, it enters the `modifying` state\. You can only modify an EC2 Fleet that is of type `maintain`\. You cannot modify an EC2 Fleet of type `request` or `instant`\. You can modify the following parameters of an EC2 Fleet: + `target-capacity-specification` – Increase or decrease the target capacity for `TotalTargetCapacity`, `OnDemandTargetCapacity`, and `SpotTargetCapacity`\. + `excess-capacity-termination-policy` – Whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the fleet\. Valid values are `no-termination` and `termination`\. When you increase the target capacity, the EC2 Fleet launches the additional instances according to the instance purchasing option specified for `DefaultTargetCapacityType`, which are either On\-Demand Instances or Spot Instances\. If the `DefaultTargetCapacityType` is `spot`, the EC2 Fleet launches the additional Spot Instances according to its allocation strategy\. If the allocation strategy is `lowest-price`, the fleet launches the instances from the lowest\-priced Spot Instance pool in the request\. If the allocation strategy is `diversified`, the fleet distributes the instances across the pools in the request\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
f3218eab695c-1
When you decrease the target capacity, the EC2 Fleet deletes any open requests that exceed the new target capacity\. You can request that the fleet terminate instances until the size of the fleet reaches the new target capacity\. If the allocation strategy is `lowest-price`, the fleet terminates the instances with the highest price per unit\. If the allocation strategy is `diversified`, the fleet terminates instances across the pools\. Alternatively, you can request that EC2 Fleet keep the fleet at its current size, but not replace any Spot Instances that are interrupted or any instances that you terminate manually\. When an EC2 Fleet terminates a Spot Instance because the target capacity was decreased, the instance receives a Spot Instance interruption notice\. **To modify an EC2 Fleet \(AWS CLI\)** Use the [modify\-fleet](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-fleet.html) command to update the target capacity of the specified EC2 Fleet\. ``` aws ec2 modify-fleet \ --fleet-id fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE \ --target-capacity-specification TotalTargetCapacity=20 ``` If you are decreasing the target capacity but want to keep the fleet at its current size, you can modify the previous command as follows\. ``` aws ec2 modify-fleet \
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
f3218eab695c-2
``` aws ec2 modify-fleet \ --fleet-id fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE \ --target-capacity-specification TotalTargetCapacity=10 \ --excess-capacity-termination-policy no-termination ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
a2068bdd9c09-0
If you no longer require an EC2 Fleet, you can delete it\. After you delete a fleet, it launches no new instances\. You must specify whether the EC2 Fleet must terminate its instances\. If you specify that the instances must be terminated when the fleet is deleted, it enters the `deleted_terminating` state\. Otherwise, it enters the `deleted_running` state, and the instances continue to run until they are interrupted or you terminate them manually\. You can only delete fleets of type `request` and `maintain`\. You cannot delete an `instant` EC2 Fleet\. **To delete an EC2 Fleet \(AWS CLI\)** Use the [delete\-fleets](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-fleets.html) command and the `--terminate-instances` parameter to delete the specified EC2 Fleet and terminate the instances\. ``` aws ec2 delete-fleets \ --fleet-ids fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE \ --terminate-instances ``` The following is example output\. ``` { "UnsuccessfulFleetDeletions": [], "SuccessfulFleetDeletions": [ { "CurrentFleetState": "deleted_terminating", "PreviousFleetState": "active",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
a2068bdd9c09-1
{ "CurrentFleetState": "deleted_terminating", "PreviousFleetState": "active", "FleetId": "fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE" } ] } ``` You can modify the previous command using the `--no-terminate-instances` parameter to delete the specified EC2 Fleet without terminating the instances\. ``` aws ec2 delete-fleets \ --fleet-ids fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE \ --no-terminate-instances ``` The following is example output\. ``` { "UnsuccessfulFleetDeletions": [], "SuccessfulFleetDeletions": [ { "CurrentFleetState": "deleted_running", "PreviousFleetState": "active", "FleetId": "fleet-4b8aaae8-dfb5-436d-a4c6-3dafa4c6b7dcEXAMPLE" } ] } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
2d6987526dd5-0
If an EC2 Fleet fails to delete, `UnsuccessfulFleetDeletions` returns the ID of the EC2 Fleet, an error code, and an error message\. The error codes are `fleetIdDoesNotExist`, `fleetIdMalformed`, `fleetNotInDeletableState`, and `unexpectedError`\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/manage-ec2-fleet.md
03a298004af1-0
Applications must sign their API requests with AWS credentials\. Therefore, if you are an application developer, you need a strategy for managing credentials for your applications that run on EC2 instances\. For example, you can securely distribute your AWS credentials to the instances, enabling the applications on those instances to use your credentials to sign requests, while protecting your credentials from other users\. However, it's challenging to securely distribute credentials to each instance, especially those that AWS creates on your behalf, such as Spot Instances or instances in Auto Scaling groups\. You must also be able to update the credentials on each instance when you rotate your AWS credentials\. We designed IAM roles so that your applications can securely make API requests from your instances, without requiring you to manage the security credentials that the applications use\. Instead of creating and distributing your AWS credentials, you can delegate permission to make API requests using IAM roles as follows: 1. Create an IAM role\. 1. Define which accounts or AWS services can assume the role\. 1. Define which API actions and resources the application can use after assuming the role\. 1. Specify the role when you launch your instance, or attach the role to an existing instance\. 1. Have the application retrieve a set of temporary credentials and use them\. For example, you can use IAM roles to grant permissions to applications running on your instances that need to use a bucket in Amazon S3\. You can specify permissions for IAM roles by creating a policy in JSON format\. These are similar to the policies that you create for IAM users\. If you change a role, the change is propagated to all instances\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
03a298004af1-1
When creating IAM roles, associate least privilege IAM policies that restrict access to the specific API calls the application requires\. You cannot attach multiple IAM roles to a single instance, but you can attach a single IAM role to multiple instances\. For more information about creating and using IAM roles, see [Roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/WorkingWithRoles.html) in the *IAM User Guide*\. You can apply resource\-level permissions to your IAM policies to control the users' ability to attach, replace, or detach IAM roles for an instance\. For more information, see [Supported resource\-level permissions for Amazon EC2 API actions](iam-policy-structure.md#ec2-supported-iam-actions-resources) and the following example: [Example: Working with IAM roles](ExamplePolicies_EC2.md#iam-example-iam-roles)\. **Topics** + [Instance profiles](#ec2-instance-profile) + [Retrieving security credentials from instance metadata](#instance-metadata-security-credentials) + [Granting an IAM user permission to pass an IAM role to an instance](#permission-to-pass-iam-roles) + [Working with IAM roles](#working-with-iam-roles)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
19fc73fb38fe-0
Amazon EC2 uses an *instance profile* as a container for an IAM role\. When you create an IAM role using the IAM console, the console creates an instance profile automatically and gives it the same name as the role to which it corresponds\. If you use the Amazon EC2 console to launch an instance with an IAM role or to attach an IAM role to an instance, you choose the role based on a list of instance profile names\. If you use the AWS CLI, API, or an AWS SDK to create a role, you create the role and instance profile as separate actions, with potentially different names\. If you then use the AWS CLI, API, or an AWS SDK to launch an instance with an IAM role or to attach an IAM role to an instance, specify the instance profile name\. An instance profile can contain only one IAM role\. This limit cannot be increased\. For more information, see [Instance Profiles](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) in the *IAM User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
17a01c3d7506-0
An application on the instance retrieves the security credentials provided by the role from the instance metadata item `iam/security-credentials/`*role\-name*\. The application is granted the permissions for the actions and resources that you've defined for the role through the security credentials associated with the role\. These security credentials are temporary and we rotate them automatically\. We make new credentials available at least five minutes before the expiration of the old credentials\. **Warning** If you use services that use instance metadata with IAM roles, ensure that you don't expose your credentials when the services make HTTP calls on your behalf\. The types of services that could expose your credentials include HTTP proxies, HTML/CSS validator services, and XML processors that support XML inclusion\. The following command retrieves the security credentials for an IAM role named `s3access`\. ------
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
97c214bfc31b-0
``` [ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \ && curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access ``` ------
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
1fb06d586eee-0
``` [ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access ``` ------ The following is example output\. ``` { "Code" : "Success", "LastUpdated" : "2012-04-26T16:39:16Z", "Type" : "AWS-HMAC", "AccessKeyId" : "ASIAIOSFODNN7EXAMPLE", "SecretAccessKey" : "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "Token" : "token", "Expiration" : "2017-05-17T15:09:54Z" } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
1fb06d586eee-1
"Expiration" : "2017-05-17T15:09:54Z" } ``` For applications, AWS CLI, and Tools for Windows PowerShell commands that run on the instance, you do not have to explicitly get the temporary security credentials—the AWS SDKs, AWS CLI, and Tools for Windows PowerShell automatically get the credentials from the EC2 instance metadata service and use them\. To make a call outside of the instance using temporary security credentials \(for example, to test IAM policies\), you must provide the access key, secret key, and the session token\. For more information, see [Using Temporary Security Credentials to Request Access to AWS Resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html) in the *IAM User Guide*\. For more information about instance metadata, see [Instance metadata and user data](ec2-instance-metadata.md)\. For information about the instance metadata IP address, see [Retrieving instance metadata](instancedata-data-retrieval.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
b1685efdb07a-0
To enable an IAM user to launch an instance with an IAM role or to attach or replace an IAM role for an existing instance, you must grant the user permission to pass the role to the instance\. The following IAM policy grants users permission to launch instances \(`ec2:RunInstances`\) with an IAM role, or to attach or replace an IAM role for an existing instance \(`ec2:AssociateIamInstanceProfile` and `ec2:ReplaceIamInstanceProfileAssociation`\)\. ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:RunInstances", "ec2:AssociateIamInstanceProfile", "ec2:ReplaceIamInstanceProfileAssociation" ], "Resource": "*" }, { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "*" } ] } ``` This policy grants IAM users access to all your roles by specifying the resource as "\*" in the policy\. However, consider whether users who launch instances with your roles \(ones that exist or that you create later on\) might be granted permissions that they don't need or shouldn't have\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
3ae73c1a1526-0
You can create an IAM role and attach it to an instance during or after launch\. You can also replace or detach an IAM role for an instance\. **Topics** + [Creating an IAM role](#create-iam-role) + [Launching an instance with an IAM role](#launch-instance-with-role) + [Attaching an IAM role to an instance](#attach-iam-role) + [Replacing an IAM role](#replace-iam-role) + [Detaching an IAM role](#detach-iam-role)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
f75cb6a0e5e5-0
You must create an IAM role before you can launch an instance with that role or attach it to an instance\.<a name="create-iam-role-console"></a> **To create an IAM role using the IAM console** 1. Open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. In the navigation pane, choose **Roles**, **Create role**\. 1. On the **Select role type** page, choose **EC2** and the **EC2** use case\. Choose **Next: Permissions**\. 1. On the **Attach permissions policy** page, select an AWS managed policy that grants your instances access to the resources that they need\. 1. On the **Review** page, enter a name for the role and choose **Create role**\. Alternatively, you can use the AWS CLI to create an IAM role\. The following example creates an IAM role with a policy that allows the role to use an Amazon S3 bucket\.<a name="create-iam-role-cli"></a> **To create an IAM role and instance profile \(AWS CLI\)** 1. Create the following trust policy and save it in a text file named `ec2-role-trust-policy.json`\. ``` {
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
f75cb6a0e5e5-1
``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com"}, "Action": "sts:AssumeRole" } ] } ``` 1. Create the `s3access` role and specify the trust policy that you created using the [create\-role](https://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html) command\. ``` aws iam create-role --role-name s3access --assume-role-policy-document file://ec2-role-trust-policy.json { "Role": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" } } ] }, "RoleId": "AROAIIZKPBKS2LEXAMPLE",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
f75cb6a0e5e5-2
} ] }, "RoleId": "AROAIIZKPBKS2LEXAMPLE", "CreateDate": "2013-12-12T23:46:37.247Z", "RoleName": "s3access", "Path": "/", "Arn": "arn:aws:iam::123456789012:role/s3access" } } ``` 1. Create an access policy and save it in a text file named `ec2-role-access-policy.json`\. For example, this policy grants administrative permissions for Amazon S3 to applications running on the instance\. ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["s3:*"], "Resource": ["*"] } ] } ``` 1. Attach the access policy to the role using the [put\-role\-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/put-role-policy.html) command\. ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
f75cb6a0e5e5-3
``` aws iam put-role-policy --role-name s3access --policy-name S3-Permissions --policy-document file://ec2-role-access-policy.json ``` 1. Create an instance profile named `s3access-profile` using the [create\-instance\-profile](https://docs.aws.amazon.com/cli/latest/reference/iam/create-instance-profile.html) command\. ``` aws iam create-instance-profile --instance-profile-name s3access-profile { "InstanceProfile": { "InstanceProfileId": "AIPAJTLBPJLEGREXAMPLE", "Roles": [], "CreateDate": "2013-12-12T23:53:34.093Z", "InstanceProfileName": "s3access-profile", "Path": "/", "Arn": "arn:aws:iam::123456789012:instance-profile/s3access-profile" } } ``` 1. Add the `s3access` role to the `s3access-profile` instance profile\. ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
f75cb6a0e5e5-4
1. Add the `s3access` role to the `s3access-profile` instance profile\. ``` aws iam add-role-to-instance-profile --instance-profile-name s3access-profile --role-name s3access ``` Alternatively, you can use the following AWS Tools for Windows PowerShell commands: + [New\-IAMRole](https://docs.aws.amazon.com/powershell/latest/reference/items/New-IAMRole.html) + [Register\-IAMRolePolicy](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-IAMRolePolicy.html) + [New\-IAMInstanceProfile](https://docs.aws.amazon.com/powershell/latest/reference/items/New-IAMInstanceProfile.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
16b136ca38b0-0
After you've created an IAM role, you can launch an instance, and associate that role with the instance during launch\. **Important** After you create an IAM role, it may take several seconds for the permissions to propagate\. If your first attempt to launch an instance with a role fails, wait a few seconds before trying again\. For more information, see [Troubleshooting Working with Roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/RolesTroubleshooting.html) in the *IAM User Guide*\.<a name="launch-instance-with-role-console"></a> **To launch an instance with an IAM role \(console\)** 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. On the dashboard, choose **Launch Instance**\. 1. Select an AMI and instance type and then choose **Next: Configure Instance Details**\. 1. On the **Configure Instance Details** page, for **IAM role**, select the IAM role that you created\. **Note**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
16b136ca38b0-1
**Note** The **IAM role** list displays the name of the instance profile that you created when you created your IAM role\. If you created your IAM role using the console, the instance profile was created for you and given the same name as the role\. If you created your IAM role using the AWS CLI, API, or an AWS SDK, you may have named your instance profile differently\. 1. Configure any other details, then follow the instructions through the rest of the wizard, or choose **Review and Launch** to accept default settings and go directly to the **Review Instance Launch** page\. 1. Review your settings, then choose **Launch** to choose a key pair and launch your instance\. 1. If you are using the Amazon EC2 API actions in your application, retrieve the AWS security credentials made available on the instance and use them to sign the requests\. The AWS SDK does this for you\. ------
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
31f177595037-0
``` [ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \ && curl -H "X-aws-ec2-metadata-token: $TOKEN" –v http://169.254.169.254/latest/meta-data/iam/security-credentials/role_name ``` ------
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
10953f57b6fe-0
``` [ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/role_name ``` ------ Alternatively, you can use the AWS CLI to associate a role with an instance during launch\. You must specify the instance profile in the command\.<a name="launch-instance-with-role-cli"></a> **To launch an instance with an IAM role \(AWS CLI\)** 1. Use the [run\-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html) command to launch an instance using the instance profile\. The following example shows how to launch an instance with the instance profile\. ``` aws ec2 run-instances --image-id ami-11aa22bb --iam-instance-profile Name="s3access-profile" --key-name my-key-pair --security-groups my-security-group --subnet-id subnet-1a2b3c4d ``` Alternatively, use the [New\-EC2Instance](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Instance.html) Tools for Windows PowerShell command\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
10953f57b6fe-1
1. If you are using the Amazon EC2 API actions in your application, retrieve the AWS security credentials made available on the instance and use them to sign the requests\. The AWS SDK does this for you\. ``` curl http://169.254.169.254/latest/meta-data/iam/security-credentials/role_name ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
d6ba134687eb-0
To attach an IAM role to an instance that has no role, the instance can be in the `stopped` or `running` state\.<a name="attach-iam-role-console"></a> **To attach an IAM role to an instance \(console\)** 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. In the navigation pane, choose **Instances**\. 1. Select the instance, choose **Actions**, **Instance Settings**, **Attach/Replace IAM role**\. 1. Select the IAM role to attach to your instance, and choose **Apply**\.<a name="attach-iam-role-instance-cli"></a> **To attach an IAM role to an instance \(AWS CLI\)** 1. If required, describe your instances to get the ID of the instance to which to attach the role\. ``` aws ec2 describe-instances ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
d6ba134687eb-1
``` aws ec2 describe-instances ``` 1. Use the [associate\-iam\-instance\-profile](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-iam-instance-profile.html) command to attach the IAM role to the instance by specifying the instance profile\. You can use the Amazon Resource Name \(ARN\) of the instance profile, or you can use its name\. ``` aws ec2 associate-iam-instance-profile --instance-id i-1234567890abcdef0 --iam-instance-profile Name="TestRole-1" { "IamInstanceProfileAssociation": { "InstanceId": "i-1234567890abcdef0", "State": "associating", "AssociationId": "iip-assoc-0dbd8529a48294120", "IamInstanceProfile": { "Id": "AIPAJLNLDX3AMYZNWYYAY", "Arn": "arn:aws:iam::123456789012:instance-profile/TestRole-1" } } } ``` Alternatively, use the following Tools for Windows PowerShell commands:
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
d6ba134687eb-2
} } } ``` Alternatively, use the following Tools for Windows PowerShell commands: + [Get\-EC2Instance](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Instance.html) + [Register\-EC2IamInstanceProfile](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2IamInstanceProfile.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
e9d9cb1f30a9-0
To replace the IAM role on an instance that already has an attached IAM role, the instance must be in the `running` state\. You can do this if you want to change the IAM role for an instance without detaching the existing one first\. For example, you can do this to ensure that API actions performed by applications running on the instance are not interrupted\.<a name="replace-iam-role-console"></a> **To replace an IAM role for an instance \(console\)** 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. In the navigation pane, choose **Instances**\. 1. Select the instance, choose **Actions**, **Instance Settings**, **Attach/Replace IAM role**\. 1. Select the IAM role to attach to your instance, and choose **Apply**\.<a name="replace-iam-role-cli"></a> **To replace an IAM role for an instance \(AWS CLI\)** 1. If required, describe your IAM instance profile associations to get the association ID for the IAM instance profile to replace\. ``` aws ec2 describe-iam-instance-profile-associations ```
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
e9d9cb1f30a9-1
``` aws ec2 describe-iam-instance-profile-associations ``` 1. Use the [replace\-iam\-instance\-profile\-association](https://docs.aws.amazon.com/cli/latest/reference/ec2/replace-iam-instance-profile-association.html) command to replace the IAM instance profile by specifying the association ID for the existing instance profile and the ARN or name of the instance profile that should replace it\. ``` aws ec2 replace-iam-instance-profile-association --association-id iip-assoc-0044d817db6c0a4ba --iam-instance-profile Name="TestRole-2" { "IamInstanceProfileAssociation": { "InstanceId": "i-087711ddaf98f9489", "State": "associating", "AssociationId": "iip-assoc-09654be48e33b91e0", "IamInstanceProfile": { "Id": "AIPAJCJEDKX7QYHWYK7GS", "Arn": "arn:aws:iam::123456789012:instance-profile/TestRole-2" } } } ``` Alternatively, use the following Tools for Windows PowerShell commands:
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
e9d9cb1f30a9-2
} } } ``` Alternatively, use the following Tools for Windows PowerShell commands: + [Get\-EC2IamInstanceProfileAssociation](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2IamInstanceProfileAssociation.html) + [Set\-EC2IamInstanceProfileAssociation](https://docs.aws.amazon.com/powershell/latest/reference/items/Set-EC2IamInstanceProfileAssociation.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
bf69f129489c-0
You can detach an IAM role from a running or stopped instance\. <a name="detach-iam-role-console"></a> **To detach an IAM role from an instance \(console\)** 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. In the navigation pane, choose **Instances**\. 1. Select the instance, choose **Actions**, **Instance Settings**, **Attach/Replace IAM role**\. 1. For **IAM role**, choose **No Role**\. Choose **Apply**\. 1. In the confirmation dialog box, choose **Yes, Detach**\.<a name="detach-iam-role-cli"></a> **To detach an IAM role from an instance \(AWS CLI\)** 1. If required, use [describe\-iam\-instance\-profile\-associations](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-iam-instance-profile-associations.html) to describe your IAM instance profile associations and get the association ID for the IAM instance profile to detach\. ``` aws ec2 describe-iam-instance-profile-associations {
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
bf69f129489c-1
``` aws ec2 describe-iam-instance-profile-associations { "IamInstanceProfileAssociations": [ { "InstanceId": "i-088ce778fbfeb4361", "State": "associated", "AssociationId": "iip-assoc-0044d817db6c0a4ba", "IamInstanceProfile": { "Id": "AIPAJEDNCAA64SSD265D6", "Arn": "arn:aws:iam::123456789012:instance-profile/TestRole-2" } } ] } ``` 1. Use the [disassociate\-iam\-instance\-profile](https://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-iam-instance-profile.html) command to detach the IAM instance profile using its association ID\. ``` aws ec2 disassociate-iam-instance-profile --association-id iip-assoc-0044d817db6c0a4ba { "IamInstanceProfileAssociation": { "InstanceId": "i-087711ddaf98f9489",
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
bf69f129489c-2
"IamInstanceProfileAssociation": { "InstanceId": "i-087711ddaf98f9489", "State": "disassociating", "AssociationId": "iip-assoc-0044d817db6c0a4ba", "IamInstanceProfile": { "Id": "AIPAJEDNCAA64SSD265D6", "Arn": "arn:aws:iam::123456789012:instance-profile/TestRole-2" } } } ``` Alternatively, use the following Tools for Windows PowerShell commands: + [Get\-EC2IamInstanceProfileAssociation](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2IamInstanceProfileAssociation.html) + [Unregister\-EC2IamInstanceProfile](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2IamInstanceProfile.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/iam-roles-for-amazon-ec2.md
1d6252c95e74-0
Your security credentials identify you to services in AWS and grant you unlimited use of your AWS resources, such as your Amazon EC2 resources\. You can use features of Amazon EC2 and AWS Identity and Access Management \(IAM\) to allow other users, services, and applications to use your Amazon EC2 resources without sharing your security credentials\. You can use IAM to control how other users use resources in your AWS account, and you can use security groups to control access to your Amazon EC2 instances\. You can choose to allow full use or limited use of your Amazon EC2 resources\. **Topics** + [Network access to your instance](#intro-to-security-groups) + [Amazon EC2 permission attributes](#AmazonEC2Permissions) + [IAM and Amazon EC2](#intro-to-iam) + [IAM policies for Amazon EC2](iam-policies-for-amazon-ec2.md) + [IAM roles for Amazon EC2](iam-roles-for-amazon-ec2.md) + [Authorizing inbound traffic for your Linux instances](authorizing-access-to-an-instance.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
7a361ec8a52f-0
A security group acts as a firewall that controls the traffic allowed to reach one or more instances\. When you launch an instance, you assign it one or more security groups\. You add rules to each security group that control traffic for the instance\. You can modify the rules for a security group at any time; the new rules are automatically applied to all instances to which the security group is assigned\. For more information, see [Authorizing inbound traffic for your Linux instances](authorizing-access-to-an-instance.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
5fea9452ba6d-0
Your organization might have multiple AWS accounts\. Amazon EC2 enables you to specify additional AWS accounts that can use your Amazon Machine Images \(AMIs\) and Amazon EBS snapshots\. These permissions work at the AWS account level only; you can't restrict permissions for specific users within the specified AWS account\. All users in the AWS account that you've specified can use the AMI or snapshot\. Each AMI has a `LaunchPermission` attribute that controls which AWS accounts can access the AMI\. For more information, see [Making an AMI public](sharingamis-intro.md)\. Each Amazon EBS snapshot has a `createVolumePermission` attribute that controls which AWS accounts can use the snapshot\. For more information, see [Sharing an Amazon EBS snapshot](ebs-modifying-snapshot-permissions.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
98e9bc72dd15-0
IAM enables you to do the following: + Create users and groups under your AWS account + Assign unique security credentials to each user under your AWS account + Control each user's permissions to perform tasks using AWS resources + Allow the users in another AWS account to share your AWS resources + Create roles for your AWS account and define the users or services that can assume them + Use existing identities for your enterprise to grant permissions to perform tasks using AWS resources By using IAM with Amazon EC2, you can control whether users in your organization can perform a task using specific Amazon EC2 API actions and whether they can use specific AWS resources\. This topic helps you answer the following questions: + How do I create groups and users in IAM? + How do I create a policy? + What IAM policies do I need to carry out tasks in Amazon EC2? + How do I grant permissions to perform actions in Amazon EC2? + How do I grant permissions to perform actions on specific resources in Amazon EC2?
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
f4a22568b835-0
**To create an IAM group** 1. Open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. In the navigation pane, choose **Groups** and then choose **Create New Group**\. 1. For **Group Name**, enter a name for your group, and then choose **Next Step**\. 1. On the **Attach Policy** page, select an AWS managed policy and then choose **Next Step**\. For example, for Amazon EC2, one of the following AWS managed policies might meet your needs: + PowerUserAccess + ReadOnlyAccess + AmazonEC2FullAccess + AmazonEC2ReadOnlyAccess 1. Choose **Create Group**\. Your new group is listed under **Group Name**\. **To create an IAM user, add the user to your group, and create a password for the user** 1. In the navigation pane, choose **Users**, **Add user**\. 1. For **User name**, enter a user name\. 1. For **Access type**, select both **Programmatic access** and **AWS Management Console access**\. 1. For **Console password**, choose one of the following:
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
f4a22568b835-1
1. For **Console password**, choose one of the following: + **Autogenerated password**\. Each user gets a randomly generated password that meets the current password policy in effect \(if any\)\. You can view or download the passwords when you get to the **Final** page\. + **Custom password**\. Each user is assigned the password that you enter in the box\. 1. Choose **Next: Permissions**\. 1. On the **Set permissions** page, choose **Add user to group**\. Select the check box next to the group that you created earlier and choose **Next: Review**\. 1. Choose **Create user**\. 1. To view the users' access keys \(access key IDs and secret access keys\), choose **Show** next to each password and secret access key to see\. To save the access keys, choose **Download \.csv** and then save the file to a safe location\. **Important** You cannot retrieve the secret access key after you complete this step; if you misplace it you must create a new one\. 1. Choose **Close**\. 1. Give each user his or her credentials \(access keys and password\); this enables them to use services based on the permissions you specified for the IAM group\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
296def5877cf-0
For more information about IAM, see the following: + [IAM policies for Amazon EC2](iam-policies-for-amazon-ec2.md) + [IAM roles for Amazon EC2](iam-roles-for-amazon-ec2.md) + [AWS Identity and Access Management \(IAM\)](https://aws.amazon.com/iam) + [IAM User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/security-iam.md
423b35249a61-0
*A shared AMI* is an AMI that a developer created and made available for other developers to use\. One of the easiest ways to get started with Amazon EC2 is to use a shared AMI that has the components you need and then add custom content\. You can also create your own AMIs and share them with others\. You use a shared AMI at your own risk\. Amazon can't vouch for the integrity or security of AMIs shared by other Amazon EC2 users\. Therefore, you should treat shared AMIs as you would any foreign code that you might consider deploying in your own data center and perform the appropriate due diligence\. We recommend that you get an AMI from a trusted source\. Amazon's public images have an aliased owner, which appears as `amazon` in the account field\. This enables you to find AMIs from Amazon easily\. Other users can't alias their AMIs\. For information about creating an AMI, see [Creating an Instance Store\-Backed Linux AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html) or [Creating an Amazon EBS\-Backed Linux AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html) \. For more information about building, delivering, and maintaining your applications on the AWS Marketplace, see the [AWS Marketplace Documentation](https://docs.aws.amazon.com/marketplace/)\. **Topics** + [Finding shared AMIs](usingsharedamis-finding.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/sharing-amis.md
423b35249a61-1
**Topics** + [Finding shared AMIs](usingsharedamis-finding.md) + [Making an AMI public](sharingamis-intro.md) + [Sharing an AMI with specific AWS accounts](sharingamis-explicit.md) + [Using bookmarks](using-bookmarks.md) + [Guidelines for shared Linux AMIs](building-shared-amis.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/sharing-amis.md
59bb99982de6-0
To help you track your Spot Instance requests and plan your use of Spot Instances, use the request status provided by Amazon EC2\. For example, the request status can provide the reason why your Spot request isn't fulfilled yet, or list the constraints that are preventing the fulfillment of your Spot request\. At each step of the process—also called the Spot request *lifecycle*—specific events determine successive request states\. **Topics** + [Lifecycle of a Spot request](#spot-instances-request-status-lifecycle) + [Getting request status information](#get-spot-instance-request-status) + [Spot request status codes](#spot-instance-request-status-understand)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-0
The following diagram shows you the paths that your Spot request can follow throughout its lifecycle, from submission to termination\. Each step is depicted as a node, and the status code for each node describes the status of the Spot request and Spot Instance\. ![\[Life cycle of a Spot Instance request\]](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/images/spot-request-status-diagram.png) **Pending evaluation** As soon as you create a Spot Instance request, it goes into the `pending-evaluation` state unless one or more request parameters are not valid \(`bad-parameters`\)\. | Status code | Request state | Instance state | | --- | --- | --- | | pending\-evaluation | open | n/a | | bad\-parameters | closed | n/a | **Holding** If one or more request constraints are valid but can't be met yet, or if there is not enough capacity, the request goes into a holding state waiting for the constraints to be met\. The request options affect the likelihood of the request being fulfilled\. For example, if you specify a maximum price below the current Spot price, your request stays in a holding state until the Spot price goes below your maximum price\. If you specify an Availability Zone group, the request stays in a holding state until the Availability Zone constraint is met\. In the event of an outage of one of the Availability Zones, there is a chance that the spare EC2 capacity available for Spot Instance requests in other Availability Zones can be affected\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-1
In the event of an outage of one of the Availability Zones, there is a chance that the spare EC2 capacity available for Spot Instance requests in other Availability Zones can be affected\. | Status code | Request state | Instance state | | --- | --- | --- | | capacity\-not\-available | open | n/a | | price\-too\-low | open | n/a | | not\-scheduled\-yet | open | n/a | | launch\-group\-constraint | open | n/a | | az\-group\-constraint | open | n/a | | placement\-group\-constraint | open | n/a | | constraint\-not\-fulfillable | open | n/a | **Pending evaluation/fulfillment\-terminal** Your Spot Instance request can go to a `terminal` state if you create a request that is valid only during a specific time period and this time period expires before your request reaches the pending fulfillment phase\. It might also happen if you cancel the request, or if a system error occurs\. | Status code | Request state | Instance state | | --- | --- | --- | | schedule\-expired | cancelled | n/a | | canceled\-before\-fulfillment\* | cancelled | n/a | | bad\-parameters | failed | n/a | | system\-error | closed | n/a | \* If you cancel the request\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-2
| system\-error | closed | n/a | \* If you cancel the request\. **Pending fulfillment** When the constraints you specified \(if any\) are met and your maximum price is equal to or higher than the current Spot price, your Spot request goes into the `pending-fulfillment` state\. At this point, Amazon EC2 is getting ready to provision the instances that you requested\. If the process stops at this point, it is likely to be because it was canceled by the user before a Spot Instance was launched\. It may also be because an unexpected system error occurred\. | Status code | Request state | Instance state | | --- | --- | --- | | pending\-fulfillment | open | n/a | **Fulfilled** When all the specifications for your Spot Instances are met, your Spot request is fulfilled\. Amazon EC2 launches the Spot Instances, which can take a few minutes\. If a Spot Instance is hibernated or stopped when interrupted, it remains in this state until the request can be fulfilled again or the request is canceled\. | Status code | Request state | Instance state | | --- | --- | --- | | fulfilled | active | pending → running | | fulfilled | active | stopped → running | If you stop a Spot Instance, your Spot request goes into the `marked-for-stop` or `instance-stopped-by-user` state until the Spot Instance can be started again or the request is cancelled\. | Status code | Request state | Instance state |
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-3
| Status code | Request state | Instance state | | --- | --- | --- | | marked\-for\-stop | active | stopping | | instance\-stopped\-by\-user\* | disabled or cancelled\*\* | stopped | \* A Spot Instance goes into the `instance-stopped-by-user` state if you stop the instance or run the shutdown command from the instance\. After you've stopped the instance, you can start it again\. On restart, the Spot Instance request returns to the `pending-evaluation` state and then Amazon EC2 launches a new Spot Instance when the constraints are met\. \*\* The Spot request state is `disabled` if you stop the Spot Instance but do not cancel the request\. The request state is `cancelled` if your spot instance is stopped and the request expires\. **Fulfilled\-terminal** Your Spot Instances continue to run as long as your maximum price is at or above the Spot price, there is available capacity for your instance type, and you don't terminate the instance\. If a change in the Spot price or available capacity requires Amazon EC2 to terminate your Spot Instances, the Spot request goes into a terminal state\. A request also goes into the terminal state if you cancel the Spot request or terminate the Spot Instances\. | Status code | Request state | Instance state | | --- | --- | --- | | request\-canceled\-and\-instance\-running | cancelled | running | | marked\-for\-stop | active | running |
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-4
| request\-canceled\-and\-instance\-running | cancelled | running | | marked\-for\-stop | active | running | | marked\-for\-termination | active | running | | instance\-stopped\-by\-price | disabled | stopped | | instance\-stopped\-by\-user | disabled | stopped | | instance\-stopped\-no\-capacity | disabled | stopped | | instance\-terminated\-by\-price | closed \(one\-time\), open\(persistent\) | terminated | | instance\-terminated\-by\-schedule | closed | terminated | | instance\-terminated\-by\-service | cancelled | terminated | | instance\-terminated\-by\-user | closed or cancelled \* | terminated | | instance\-terminated\-no\-capacity | closed \(one\-time\), open \(persistent\) | terminated | | instance\-terminated\-launch\-group\-constraint | closed \(one\-time\), open \(persistent\) | terminated | \* The request state is `closed` if you terminate the instance but do not cancel the request\. The request state is `cancelled` if you terminate the instance and cancel the request\. Even if you terminate a Spot Instance before you cancel its request, there might be a delay before Amazon EC2 detects that your Spot Instance was terminated\. In this case, the request state can either be `closed` or `cancelled`\. **Persistent requests**
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
397839043875-5
**Persistent requests** When your Spot Instances are terminated \(either by you or Amazon EC2\), if the Spot request is a persistent request, it returns to the `pending-evaluation` state and then Amazon EC2 can launch a new Spot Instance when the constraints are met\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
47cfcbad2f5f-0
You can get request status information using the AWS Management Console or a command line tool\. **To get request status information \(console\)** 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. In the navigation pane, choose **Spot Requests** and select the Spot request\. 1. To check the status, on the **Description** tab, check the **Status** field\. **To get request status information using the command line** You can use one of the following commands\. For more information about these command line interfaces, see [Accessing Amazon EC2](concepts.md#access-ec2)\. + [describe\-spot\-instance\-requests](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-instance-requests.html) \(AWS CLI\) + [Get\-EC2SpotInstanceRequest](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2SpotInstanceRequest.html) \(AWS Tools for Windows PowerShell\)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
0ae3e43708f4-0
Spot request status information is composed of a status code, the update time, and a status message\. Together, these help you determine the disposition of your Spot request\. The following are the Spot request status codes: `az-group-constraint` Amazon EC2 cannot launch all the instances you requested in the same Availability Zone\. `bad-parameters` One or more parameters for your Spot request are not valid \(for example, the AMI you specified does not exist\)\. The status message indicates which parameter is not valid\. `canceled-before-fulfillment` The user canceled the Spot request before it was fulfilled\. `capacity-not-available` There is not enough capacity available for the instances that you requested\. `constraint-not-fulfillable` The Spot request can't be fulfilled because one or more constraints are not valid \(for example, the Availability Zone does not exist\)\. The status message indicates which constraint is not valid\. `fulfilled` The Spot request is `active`, and Amazon EC2 is launching your Spot Instances\. `instance-stopped-by-price` Your instance was stopped because the Spot price exceeded your maximum price\. `instance-stopped-by-user` Your instance was stopped because a user stopped the instance or ran the shutdown command from the instance\. `instance-stopped-no-capacity` Your instance was stopped because there was no longer enough Spot capacity available for the instance\. `instance-terminated-by-price`
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
0ae3e43708f4-1
Your instance was stopped because there was no longer enough Spot capacity available for the instance\. `instance-terminated-by-price` Your instance was terminated because the Spot price exceeded your maximum price\. If your request is persistent, the process restarts, so your request is pending evaluation\. `instance-terminated-by-schedule` Your Spot Instance was terminated at the end of its scheduled duration\. `instance-terminated-by-service` Your instance was terminated from a stopped state\. `instance-terminated-by-user` or `spot-instance-terminated-by-user` You terminated a Spot Instance that had been fulfilled, so the request state is `closed` \(unless it's a persistent request\) and the instance state is `terminated`\. `instance-terminated-launch-group-constraint` One or more of the instances in your launch group was terminated, so the launch group constraint is no longer fulfilled\. `instance-terminated-no-capacity` Your instance was terminated because there is no longer enough Spot capacity available for the instance\. `launch-group-constraint` Amazon EC2 cannot launch all the instances that you requested at the same time\. All instances in a launch group are started and terminated together\. `limit-exceeded`
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
0ae3e43708f4-2
`limit-exceeded` The limit on the number of EBS volumes or total volume storage was exceeded\. For more information about these limits and how to request an increase, see [Amazon EBS Limits](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_ebs) in the *Amazon Web Services General Reference*\. `marked-for-stop` The Spot Instance is marked for stopping\. `marked-for-termination` The Spot Instance is marked for termination\. `not-scheduled-yet` The Spot request is not evaluated until the scheduled date\. `pending-evaluation` After you make a Spot Instance request, it goes into the `pending-evaluation` state while the system evaluates the parameters of your request\. `pending-fulfillment` Amazon EC2 is trying to provision your Spot Instances\. `placement-group-constraint` The Spot request can't be fulfilled yet because a Spot Instance can't be added to the placement group at this time\. `price-too-low` The request can't be fulfilled yet because your maximum price is below the Spot price\. In this case, no instance is launched and your request remains `open`\. `request-canceled-and-instance-running` You canceled the Spot request while the Spot Instances are still running\. The request is `cancelled`, but the instances remain `running`\. `schedule-expired`
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
0ae3e43708f4-3
`schedule-expired` The Spot request expired because it was not fulfilled before the specified date\. `system-error` There was an unexpected system error\. If this is a recurring issue, please contact AWS Support for assistance\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/spot-request-status.md
4c5a359db58b-0
You can detach an Amazon EBS volume from an instance explicitly or by terminating the instance\. However, if the instance is running, you must first unmount the volume from the instance\. If an EBS volume is the root device of an instance, you must stop the instance before you can detach the volume\. When a volume with an AWS Marketplace product code is detached from an instance, the product code is no longer associated with the instance\. **Important** After you detach a volume, you are still charged for volume storage as long as the storage amount exceeds the limit of the AWS Free Tier\. You must delete a volume to avoid incurring further charges\. For more information, see [Deleting an Amazon EBS volume](ebs-deleting-volume.md)\. This example unmounts the volume and then explicitly detaches it from the instance\. This is useful when you want to terminate an instance or attach a volume to a different instance\. To verify that the volume is no longer attached to the instance, see [Viewing information about an Amazon EBS volume](ebs-describing-volumes.md)\. You can reattach a volume that you detached \(without unmounting it\), but it might not get the same mount point\. If there were writes to the volume in progress when it was detached, the data on the volume might be out of sync\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/ebs-detaching-volume.md
4c5a359db58b-1
You can get directions for volumes on a Windows instance from [Detaching a volume from a Windows instance](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-detaching-volume.html) in the *Amazon EC2 User Guide for Windows Instances*\. **To detach an EBS volume using the console** 1. From your Linux instance, use the following command to unmount the `/dev/sdh` device\. ``` [ec2-user ~]$ umount -d /dev/sdh ``` 1. Open the Amazon EC2 console at [https://console\.aws\.amazon\.com/ec2/](https://console.aws.amazon.com/ec2/)\. 1. In the navigation pane, choose **Volumes**\. 1. Select a volume and choose **Actions**, **Detach Volume**\. 1. In the confirmation dialog box, choose **Yes, Detach**\. **To detach an EBS volume from an instance using the command line** After unmounting the volume, you can use one of the following commands to detach it\. For more information about these command line interfaces, see [Accessing Amazon EC2](concepts.md#access-ec2)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/ebs-detaching-volume.md
4c5a359db58b-2
+ [detach\-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/detach-volume.html) \(AWS CLI\) + [Dismount\-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/Dismount-EC2Volume.html) \(AWS Tools for Windows PowerShell\)
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/ebs-detaching-volume.md
77c304a858fd-0
The following are common problems encountered when detaching volumes, and how to resolve them\. **Note** To guard against the possibility of data loss, take a snapshot of your volume before attempting to unmount it\. Forced detachment of a stuck volume can cause damage to the file system or the data it contains or an inability to attach a new volume using the same device name, unless you reboot the instance\. + If you encounter problems while detaching a volume through the Amazon EC2 console, it may be helpful to use the describe\-volumes CLI command to diagnose the issue\. For more information, see [describe\-volumes](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-volumes.html)\. + If your volume stays in the `detaching` state, you can force the detachment by choosing **Force Detach**\. Use this option only as a last resort to detach a volume from a failed instance, or if you are detaching a volume with the intention of deleting it\. The instance doesn't get an opportunity to flush file system caches or file system metadata\. If you use this option, you must perform the file system check and repair procedures\. + If you've tried to force the volume to detach multiple times over several minutes and it stays in the `detaching` state, you can post a request for help to the [Amazon EC2 forum](https://forums.aws.amazon.com/forum.jspa?forumID=30)\. To help expedite a resolution, include the volume ID and describe the steps that you've already taken\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/ebs-detaching-volume.md
77c304a858fd-1
+ When you attempt to detach a volume that is still mounted, the volume can become stuck in the `busy` state while it is trying to detach\. The following output from describe\-volumes shows an example of this condition: ``` aws ec2 describe-volumes --region us-west-2 --volume-ids vol-1234abcd { "Volumes": [ { "AvailabilityZone": "us-west-2b", "Attachments": [ { "AttachTime": "2016-07-21T23:44:52.000Z", "InstanceId": "i-fedc9876", "VolumeId": "vol-1234abcd", "State": "busy", "DeleteOnTermination": false, "Device": "/dev/sdf" } .... ``` When you encounter this state, detachment can be delayed indefinitely until you unmount the volume, force detachment, reboot the instance, or all three\.
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/ebs-detaching-volume.md
31e6c06500d8-0
C\-states control the sleep levels that a core can enter when it is idle\. C\-states are numbered starting with C0 \(the shallowest state where the core is totally awake and executing instructions\) and go to C6 \(the deepest idle state where a core is powered off\)\. P\-states control the desired performance \(in CPU frequency\) from a core\. P\-states are numbered starting from P0 \(the highest performance setting where the core is allowed to use Intel Turbo Boost Technology to increase frequency if possible\), and they go from P1 \(the P\-state that requests the maximum baseline frequency\) to P15 \(the lowest possible frequency\)\. The following instance types provide the ability for an operating system to control processor C\-states and P\-states: + General purpose: `m4.10xlarge` \| `m4.16xlarge` \| `m5.metal` \| `m5d.metal` + Compute optimized: `c4.8xlarge` \| `c5.metal` \| `c5n.metal`
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/processor_state_control.md
31e6c06500d8-1
+ Compute optimized: `c4.8xlarge` \| `c5.metal` \| `c5n.metal` + Memory optimized: `r4.8xlarge` \| `r4.16xlarge` \| `r5.metal` \| `r5d.metal` \| `u-6tb1.metal` \| `u-9tb1.metal` \| `u-12tb1.metal` \| `x1.16xlarge` \| `x1.32xlarge` \| `x1e.8xlarge` \| `x1e.16xlarge` \| `x1e.32xlarge` \| `z1d.metal` + Storage optimized: `d2.8xlarge` \| `i3.8xlarge` \| `i3.16xlarge` \| `i3.metal` \| `i3en.metal` \| `h1.8xlarge` \| `h1.16xlarge` + Accelerated computing: `f1.16xlarge` \| `g3.16xlarge` \| `g4dn.metal` \| `p2.16xlarge` \| `p3.16xlarge` The following instance types provide the ability for an operating system to control processor C\-states:
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-ec2-user-guide/doc_source/processor_state_control.md