ec2:RunInstances

Write

ec2:RunInstances is a Write access-level action in the ec2 service. Grants permission to launch one or more instances

Resource types

ARNs that ec2:RunInstances can be scoped to in an IAM policy.

arn:${Partition}:ec2:${Region}::image/${ImageId}
image
arn:${Partition}:ec2:${Region}:${Account}:instance/${InstanceId}
instance
arn:${Partition}:ec2:${Region}:${Account}:network-interface/${NetworkInterfaceId}
network-interface
arn:${Partition}:ec2:${Region}:${Account}:security-group/${SecurityGroupId}
security-group
arn:${Partition}:ec2:${Region}:${Account}:subnet/${SubnetId}
subnet
arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation/${CapacityReservationId}
capacity-reservation
arn:${Partition}:ec2:${Region}:${Account}:elastic-gpu/${ElasticGpuId}
elastic-gpu
arn:${Partition}:elastic-inference:${Region}:${Account}:elastic-inference-accelerator/${AcceleratorId}
elastic-inference
arn:${Partition}:resource-groups:${Region}:${Account}:group/${GroupName}
group
arn:${Partition}:ec2:${Region}:${Account}:key-pair/${KeyPairName}
key-pair
arn:${Partition}:ec2:${Region}:${Account}:launch-template/${LaunchTemplateId}
launch-template
arn:${Partition}:license-manager:${Region}:${Account}:license-configuration:${LicenseConfigurationId}
license-configuration
arn:${Partition}:ec2:${Region}:${Account}:placement-group/${PlacementGroupName}
placement-group
arn:${Partition}:ec2:${Region}:${Account}:secondary-interface/${SecondaryInterfaceId}
secondary-interface
arn:${Partition}:ec2:${Region}:${Account}:secondary-subnet/${SecondarySubnetId}
secondary-subnet
arn:${Partition}:ec2:${Region}::snapshot/${SnapshotId}
snapshot
arn:${Partition}:ec2:${Region}:${Account}:spot-instances-request/${SpotInstanceRequestId}
spot-instances-request
arn:${Partition}:ec2:${Region}:${Account}:volume/${VolumeId}
volume

Condition keys

Keys you can use in the Condition block of a policy that grants ec2:RunInstances.

ec2:SnapshotTime String

Filters access by the initiation time of a snapshot

aws:RequestTag/${TagKey} String

Filters access by a tag key and value pair that is allowed in the request

aws:ResourceTag/${TagKey} String

Filters access by a tag key and value pair of a resource

aws:TagKeys ArrayOfString

Filters access by a list of tag keys that are allowed in the request

ec2:Add/group String

Filters access by the group being added to a snapshot

ec2:Add/userId String

Filters access by the account id being added to a snapshot

ec2:AssociatePublicIpAddress Bool

Filters access by whether the user wants to associate a public IP address with the instance

ec2:Attribute String

Filters access by an attribute of a resource

ec2:Attribute/${AttributeName} String

Filters access by an attribute being set on a resource

ec2:AuthorizedService String

Filters access by the AWS service that has permission to use a resource

ec2:AuthorizedUser String

Filters access by an IAM principal that has permission to use a resource

ec2:AvailabilityZone String

Filters access by the name of an Availability Zone in an AWS Region

ec2:AvailabilityZoneId String

Filters access by the ID of an Availability Zone in an AWS Region

ec2:CapacityReservationFleet ARN

Filters access by the ARN of the Capacity Reservation Fleet

ec2:CommitmentDuration Numeric

Filters access by commitment duration of the Capacity Reservation

ec2:CpuOptionsAmdSevSnp String

Filters access by the state of AMD SEV-SNP CPU Options. Currently, only US East (Ohio) and Europe (Ireland) are supported

ec2:CreateDate Date

Filters access by the date and time at which the Capacity Reservation was created

ec2:DestinationCapacityReservationId ARN

Filters access by the ID of the Capacity Reservation that you want to move capacity into

ec2:EbsOptimized Bool

Filters access by whether the instance is enabled for EBS optimization

ec2:ElasticGpuType String

Filters access by the type of Elastic Graphics accelerator

ec2:Encrypted Bool

Filters access by whether the EBS volume is encrypted

ec2:PlacementGroup ARN

Filters access by the ARN of the placement group

ec2:EndDate Date

Filters access by the date and time at which the Capacity Reservation ends

ec2:PlacementGroupName String

Filters access by the name of a placement group

ec2:EndDateType String

Filters access by the way in which the Capacity Reservation ends

ec2:PlacementGroupStrategy String

Filters access by the instance placement strategy used by the placement group (cluster, spread, or partition)

ec2:EphemeralStorage Bool

Filters access by whether the instance is enabled for ephemeral storage

ec2:ProductCode String

Filters access by the product code that is associated with the AMI

ec2:Public Bool

Filters access by whether the image has public launch permissions

ec2:Region String

Filters access by the name of the AWS Region

ec2:ImageID String

Filters access by the ID of an image

ec2:ImageType String

Filters access by the type of image (machine, aki, or ari)

ec2:Remove/group String

Filters access by the group being removed from a snapshot

ec2:Remove/userId String

Filters access by the account id being removed from a snapshot

ec2:InstanceAutoRecovery String

Filters access by whether the instance type supports auto recovery

ec2:InstanceBandwidthWeighting String

Filters access by the bandwidth weighting of an instance

ec2:InstanceCount Numeric

Filters access by the number of instances

ec2:ResourceTag/${TagKey} String

Filters access by a tag key and value pair of a resource

ec2:InstanceID String

Filters access by the ID of an instance

ec2:InstanceMarketType String

Filters access by the market or purchasing option of an instance (capacity-block, on-demand, or spot)

ec2:RootDeviceType String

Filters access by the root device type of the instance (ebs or instance-store)

ec2:InstanceMatchCriteria String

Filters access by the type of instance launches that the Capacity Reservation accepts

ec2:InstanceMetadataTags String

Filters access by whether the instance allows access to instance tags from the instance metadata

ec2:InstancePlatform ARN

Filters access by the type of operating system for which the Capacity Reservation reserves capacity

ec2:InstanceProfile ARN

Filters access by the ARN of an instance profile

ec2:SecurityGroupID String

Filters access by the ID of a security group

ec2:InstanceType String

Filters access by the type of instance

ec2:SnapshotCoolOffPeriod Numeric

Filters access by the compliance mode cooling-off period

ec2:InterruptibleCapacityReservationId String

Filters access by the ID of an interruptible Capacity Reservation

ec2:SnapshotID String

Filters access by the ID of a snapshot

ec2:InterruptionType String

Filters access by the type of interruption

ec2:SnapshotLockDuration Numeric

Filters access by the snapshot lock duration

ec2:Ipv4IpamPoolId String

Filters access by the ID of an IPAM pool provided for IPv4 CIDR block allocation

ec2:SourceAvailabilityZone String

Filters access by the name of the Availability Zone from which the request originated

ec2:Ipv6IpamPoolId String

Filters access by the ID of an IPAM pool provided for IPv6 CIDR block allocation

ec2:SourceCapacityReservationId ARN

Filters access by the ID of the Capacity Reservation from which you want to move capacity

ec2:IsInterruptible Bool

Filters access by whether Capacity Reservations are interruptible

ec2:IsLaunchTemplateResource Bool

Filters access by whether users are able to override resources that are specified in the launch template

ec2:SourceOutpostArn ARN

Filters access by the ARN of the Outpost from which the request originated

ec2:KeyPairName String

Filters access by the name of a key pair

ec2:Subnet ARN

Filters access by the ARN of the subnet

ec2:KeyPairType String

Filters access by the type of a key pair

ec2:SubnetID String

Filters access by the ID of a subnet

ec2:KmsKeyId String

Filters access by the ID of an AWS KMS key provided in the request

ec2:TargetInstanceCount Numeric

Filters access by the number of instances the interruptible Capacity Reservation is assigned

ec2:LaunchTemplate ARN

Filters access by the ARN of a launch template

ec2:Tenancy String

Filters access by the tenancy of the VPC or instance (default, dedicated, or host)

ec2:Location String

Filters access by the destination for the snapshot copy

ec2:VolumeID String

Filters access by the ID of a volume

ec2:ManagedResourceOperator String

Filters access by the presence of an EC2 operator provisioning a managed resource

ec2:VolumeInitializationRate Numeric

Filters access by the initialization rate of the volume, in MiBps

ec2:MetadataHttpEndpoint String

Filters access by whether the HTTP endpoint is enabled for the instance metadata service

ec2:VolumeIops Numeric

Filters access by the the number of input/output operations per second (IOPS) provisioned for the volume

ec2:MetadataHttpPutResponseHopLimit Numeric

Filters access by the allowed number of hops when calling the instance metadata service

ec2:VolumeSize Numeric

Filters access by the size of the volume, in GiB

ec2:MetadataHttpTokens String

Filters access by whether tokens are required when calling the instance metadata service (optional or required)

ec2:VolumeThroughput Numeric

Filters access by the throughput of the volume, in MiBps

ec2:VolumeType String

Filters access by the type of volume (gp2, gp3, io1, io2, st1, sc1, or standard)

ec2:NetworkInterfaceID String

Filters access by the ID of an elastic network interface

ec2:Vpc ARN

Filters access by the ARN of the VPC

ec2:NewInstanceProfile ARN

Filters access by the ARN of the instance profile being attached

ec2:OutpostArn ARN

Filters access by the ARN of the Outpost

ec2:Owner String

Filters access by the owner of the resource (amazon, aws-marketplace, or an AWS account ID)

ec2:ParentSnapshot ARN

Filters access by the ARN of the parent snapshot

ec2:ParentVolume ARN

Filters access by the ARN of the parent volume from which the snapshot was created

ec2:Permission String

Filters access by the type of permission for a resource (INSTANCE-ATTACH or EIP-ASSOCIATE)

Dependent actions

To use ec2:RunInstances you may also need to grant:

Example IAM policy

A minimal policy that allows ec2:RunInstances. Replace "Resource": "*" with a specific ARN to follow least privilege.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowEc2RunInstances",
      "Effect": "Allow",
      "Action": "ec2:RunInstances",
      "Resource": "*"
    }
  ]
}

Related actions in ec2

View all ec2 actions →