You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: roles/ec2_instance_create_delete/README.md
+82-101
Original file line number
Diff line number
Diff line change
@@ -2,108 +2,84 @@
2
2
3
3
A role to create an EC2 instance in AWS.
4
4
5
-
Users can specify various parameters for instance configuration, including instance type, AMI ID, key pair, tags, and VPC/subnet configuration.
6
-
7
-
This role also supports the creation of optional networking resources, such as an external security group and an Elastic IP (EIP). You can choose to wait for the EC2 instance to finish booting before continuing.
5
+
Users can specify various parameters for instance configuration, including instance type, AMI ID, key pair, tags, VPC/subnet configuration, and whether to associate an EIP. You can choose to wait for the EC2 instance to finish booting before continuing.
6
+
7
+
This role can be combined with the [cloud.aws_ops.ec2_networking_resources role](../ec2_networking_resources/README.md) to create networking resources for the instance, see [examples](#examples).
8
+
9
+
## Requirements
10
+
11
+
An AWS account with the following permissions:
12
+
13
+
* ec2:AllocateAddress
14
+
* ec2:AssociateAddress
15
+
* ec2:CreateKeyPair
16
+
* ec2:DeleteKeyPair
17
+
* ec2:DescribeAddresses
18
+
* ec2:DescribeInstanceAttribute
19
+
* ec2:DescribeInstances
20
+
* ec2:DescribeInstanceStatus
21
+
* ec2:DescribeKeyPairs
22
+
* ec2:DescribeSecurityGroups
23
+
* ec2:DescribeSubnets
24
+
* ec2:DescribeVpcs
25
+
* ec2:DisassociateAddress
26
+
* ec2:ModifyInstanceAttribute
27
+
* ec2:ReleaseAddress
28
+
* ec2:RunInstances
29
+
* ec2:TerminateInstances
8
30
9
31
## Role Variables
10
32
11
33
The following variables can be set in the role to customize EC2 instance creation and networking configurations:
Whether to wait for the EC2 instance to be in the "running" (if creating an instance) or "terminated" (if deleting an instance) state before continuing. Default is `true`.
Whether to create an Elastic IP (EIP) and associate it with the EC2 instance. Default is `false`.
66
-
If set to `true` and the provided VPC doesn't have an Internet Gateway (IGW) attached, set `ec2_instance_create_delete_associate_igw` to `true`to avoid failure.
67
+
If true, EC2 instance must be launched in a VPC with an Internet Gateway (IGW) attached, otherwise this will fail. Use [cloud.aws_ops.ec2_networking_resources role](../ec2_networking_resources/README.md)to create the necessary networking resources.
A list of custom rules to add to the security group. Each rule is a dictionary with `proto`, `ports`, and `cidr_ip` keys. Default is to allow SSH (port 22) from `0.0.0.0/0`.
Copy file name to clipboardexpand all lines: roles/ec2_instance_create_delete/meta/argument_specs.yml
+16-61
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ argument_specs:
4
4
short_description: A role to create an EC2 instance with optional networking resources.
5
5
description:
6
6
- A role to create an EC2 instance.
7
-
- Optionally can create a security group and associate an Elastic IP with the instance.
8
-
- Supports custom configurations for instance settings, including instance type, AMI, key pair, tags, VPC/subnet, and networking configurations.
7
+
- Can optionally attach security groups and associate an Elastic IP with the instance.
8
+
- Supports custom configurations for instance settings including instance type, AMI, key pair, tags, VPC/subnet, and networking configurations.
9
9
options:
10
10
ec2_instance_create_delete_operation:
11
11
description:
@@ -14,101 +14,56 @@ argument_specs:
14
14
type: str
15
15
default: create
16
16
choices: [create, delete]
17
-
ec2_instance_create_delete_aws_region:
18
-
description:
19
-
- The AWS region in which to create the EC2 instance.
20
-
required: true
21
-
type: str
22
17
ec2_instance_create_delete_instance_name:
23
18
description:
24
19
- The name of the EC2 instance to be created.
25
20
required: true
26
21
type: str
27
22
ec2_instance_create_delete_instance_type:
28
23
description:
29
-
- The instance type for the EC2 instance.
30
-
required: true
24
+
- The instance type for the EC2 instance. Required when `ec2_instance_create_delete_operation` is `true`.
25
+
required: false
31
26
type: str
32
27
ec2_instance_create_delete_ami_id:
33
28
description:
34
-
- The AMI ID for the EC2 instance.
35
-
required: true
29
+
- The AMI ID for the EC2 instance. Required when `ec2_instance_create_delete_operation` is `true`.
30
+
required: false
36
31
type: str
37
32
ec2_instance_create_delete_key_name:
38
33
description:
39
-
- The name of the key pair to use for SSH access to the EC2 instance.
34
+
- The name of the key pair to use for SSH access to the EC2 instance. If the key does not exist, a key pair will be created with the name. If not provided, instance will not be accessible via SSH.
40
35
required: false
41
36
type: str
42
37
ec2_instance_create_delete_vpc_subnet_id:
43
38
description:
44
-
- The ID of the VPC subnet in which the instance will be launched.
39
+
- The ID of the VPC subnet in which the instance will be launched. If not provided, instance will be created in the default subnet for the default VPC in the AWS region, if present.
45
40
required: false
46
41
type: str
47
42
ec2_instance_create_delete_tags:
48
43
description:
49
44
- A dictionary of tags to assign to the EC2 instance.
50
45
required: false
51
46
type: dict
52
-
ec2_instance_create_delete_wait_for_boot:
47
+
ec2_instance_create_delete_wait_for_state:
53
48
description:
54
-
- Whether to wait for the EC2 instance to be in the running state before continuing.
49
+
- Whether to wait for the EC2 instance to be in the running/terminated state before continuing.
55
50
required: false
56
51
default: true
57
52
type: bool
58
-
ec2_instance_create_delete_associate_eip:
59
-
description:
60
-
- Whether to create and associate an Elastic IP (EIP) with the EC2 instance.
61
-
required: false
62
-
default: false
63
-
type: bool
64
-
ec2_instance_create_delete_associate_external_sg:
65
-
description:
66
-
- Whether to associate an existing or a new security group for external access.
- List of security group names or IDs to associate with the EC2 instance.
85
56
required: false
86
-
type: dict
87
-
ec2_instance_create_delete_associate_igw:
57
+
type: list
58
+
elements: str
59
+
ec2_instance_create_delete_associate_eip:
88
60
description:
89
-
- Whether to create and associate an internal gateway.
61
+
- Whether to create and associate an Elastic IP (EIP) with the EC2 instance.
90
62
required: false
91
63
default: false
92
64
type: bool
93
-
ec2_instance_create_delete_vpc_id:
94
-
description:
95
-
- The ID of the VPC used for security group and internet gateway.
96
-
- This is required when `ec2_instance_create_delete_associate_external_sg` or `ec2_instance_create_delete_associate_igw` is `true`.
97
-
required: false
98
-
type: str
99
65
ec2_instance_create_delete_eip_tags:
100
66
description:
101
67
- Tags to assign to the Elastic IP.
102
68
required: false
103
69
type: dict
104
-
ec2_instance_create_delete_external_sg_rules:
105
-
description:
106
-
- A list of dict containing custom rules to add to the security group. Each rule is a dictionary with `proto`, `ports`, and `cidr_ip` keys. Default is to allow SSH (port 22) from `0.0.0.0/0`.
0 commit comments