Skip to content

Commit cfebd60

Browse files
author
Sohan Yadav
authored
Merge pull request #6 from clouddrove/VOT-2
enable encryption with EBS
2 parents 6a360c1 + 0dc2a97 commit cfebd60

File tree

10 files changed

+308
-85
lines changed

10 files changed

+308
-85
lines changed

README.md

+45-69
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<hr>
3939

4040

41-
We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
41+
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
4242

4343
This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
4444

@@ -68,19 +68,18 @@ This module has a few dependencies:
6868
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-ec2/releases).
6969

7070

71-
### Simple Example
72-
Here is an example of how you can use this module in your inventory structure:
71+
Here is examples of how you can use this module in your inventory structure:
72+
### Basic Example
7373
```hcl
7474
module "ec2" {
75-
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.5"
75+
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7"
7676
name = "ec2-instance"
7777
application = "clouddrove"
7878
environment = "test"
7979
label_order = ["environment", "application", "name"]
8080
instance_count = 2
8181
ami = "ami-08d658f84a6d84a80"
8282
instance_type = "t2.nano"
83-
key_name = module.keypair.name
8483
monitoring = false
8584
tenancy = "default"
8685
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
@@ -100,81 +99,58 @@ Here is an example of how you can use this module in your inventory structure:
10099
}
101100
```
102101

102+
### Secure Example
103+
```hcl
104+
module "ec2" {
105+
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7"
106+
name = "ec2-instance"
107+
application = "clouddrove"
108+
environment = "test"
109+
label_order = ["environment", "application", "name"]
110+
instance_count = 2
111+
ami = "ami-08d658f84a6d84a80"
112+
instance_type = "t2.nano"
113+
monitoring = false
114+
tenancy = "default"
115+
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
116+
subnet_ids = tolist(module.public_subnets.public_subnet_id)
117+
assign_eip_address = true
118+
associate_public_ip_address = true
119+
instance_profile_enabled = true
120+
iam_instance_profile = module.iam-role.name
121+
disk_size = 8
122+
ebs_optimized = false
123+
ebs_volume_enabled = true
124+
ebs_volume_type = "gp2"
125+
ebs_volume_size = 30
126+
encrypted = true
127+
kms_key_id = module.kms_key.key_arn
128+
instance_tags = { "snapshot" = true }
129+
dns_zone_id = "Z1XJD7SSBKXLC1"
130+
hostname = "ec2"
131+
}
132+
```
103133

104134

105135

106136

107137

108-
## Inputs
109-
110-
| Name | Description | Type | Default | Required |
111-
|------|-------------|:----:|:-----:|:-----:|
112-
| ami | The AMI to use for the instance. | string | - | yes |
113-
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
114-
| assign_eip_address | Assign an Elastic IP address to the instance. | bool | `false` | no |
115-
| associate_public_ip_address | Associate a public IP address with the instance. | bool | `true` | no |
116-
| attributes | Additional attributes (e.g. `1`). | list | `<list>` | no |
117-
| availability_zone | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region. | list | `<list>` | no |
118-
| cpu_core_count | Sets the number of CPU cores for an instance. | string | `` | no |
119-
| cpu_credits | The credit option for CPU usage. Can be `standard` or `unlimited`. T3 instances are launched as unlimited by default. T2 instances are launched as standard by default. | string | `standard` | no |
120-
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `-` | no |
121-
| disable_api_termination | If true, enables EC2 Instance Termination Protection. | bool | `false` | no |
122-
| disk_size | Size of the root volume in gigabytes. | number | `8` | no |
123-
| dns_enabled | Flag to control the dns_enable. | bool | `false` | no |
124-
| dns_zone_id | The Zone ID of Route53. | string | `` | no |
125-
| ebs_block_device | Additional EBS block devices to attach to the instance. | list | `<list>` | no |
126-
| ebs_device_name | Name of the EBS device to mount. | list(string) | `<list>` | no |
127-
| ebs_iops | Amount of provisioned IOPS. This must be set with a volume_type of io1. | number | `0` | no |
128-
| ebs_optimized | If true, the launched EC2 instance will be EBS-optimized. | bool | `false` | no |
129-
| ebs_volume_enabled | Flag to control the ebs creation. | bool | `false` | no |
130-
| ebs_volume_size | Size of the EBS volume in gigabytes. | number | `30` | no |
131-
| ebs_volume_type | The type of EBS volume. Can be standard, gp2 or io1. | string | `gp2` | no |
132-
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
133-
| ephemeral_block_device | Customize Ephemeral (also known as Instance Store) volumes on the instance. | list | `<list>` | no |
134-
| host_id | The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host. | string | `` | no |
135-
| hostname | DNS records to create. | string | `` | no |
136-
| iam_instance_profile | The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. | string | `` | no |
137-
| instance_count | Number of instances to launch. | number | `1` | no |
138-
| instance_enabled | Flag to control the instance creation. | bool | `true` | no |
139-
| instance_initiated_shutdown_behavior | Shutdown behavior for the instance. | string | `` | no |
140-
| instance_profile_enabled | Flag to control the instance profile creation. | bool | `false` | no |
141-
| instance_tags | Instance tags. | map | `<map>` | no |
142-
| instance_type | The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance. | string | - | yes |
143-
| ipv6_address_count | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | number | `0` | no |
144-
| ipv6_addresses | List of IPv6 addresses from the range of the subnet to associate with the primary network interface. | list | `<list>` | no |
145-
| key_name | The key name to use for the instance. | string | `` | no |
146-
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
147-
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `[email protected]` | no |
148-
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0). | bool | `false` | no |
149-
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
150-
| network_interface | Customize network interfaces to be attached at instance boot time. | list(map(string)) | `<list>` | no |
151-
| placement_group | The Placement Group to start the instance in. | string | `` | no |
152-
| root_block_device | Customize details about the root block device of the instance. See Block Devices below for details. | list | `<list>` | no |
153-
| source_dest_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | bool | `true` | no |
154-
| subnet | VPC Subnet ID the instance is launched in. | string | `` | no |
155-
| subnet_ids | A list of VPC Subnet IDs to launch in. | list(string) | `<list>` | no |
156-
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
157-
| tenancy | The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command. | string | `` | no |
158-
| ttl | The TTL of the record to add to the DNS zone to complete certificate validation. | string | `300` | no |
159-
| type | Type of DNS records to create. | string | `CNAME` | no |
160-
| user_data | The Base64-encoded user data to provide when launching the instances. | string | `` | no |
161-
| vpc_security_group_ids_list | A list of security group IDs to associate with. | list(string) | `<list>` | no |
162138

163139
## Outputs
164140

165141
| Name | Description |
166142
|------|-------------|
167143
| arn | The ARN of the instance. |
168144
| az | The availability zone of the instance. |
169-
| instance_count | The count of instances. |
170-
| instance_id | The instance ID. |
171-
| ipv6_addresses | A list of assigned IPv6 addresses. |
172-
| key_name | The key name of the instance. |
173-
| placement_group | The placement group of the instance. |
174-
| private_ip | Private IP of instance. |
175-
| public_ip | Public IP of instance (or EIP). |
176-
| subnet_id | The EC2 subnet ID. |
177-
| vpc_security_group_ids | The associated security groups in non-default VPC. |
145+
| instance\_count | The count of instances. |
146+
| instance\_id | The instance ID. |
147+
| ipv6\_addresses | A list of assigned IPv6 addresses. |
148+
| key\_name | The key name of the instance. |
149+
| placement\_group | The placement group of the instance. |
150+
| private\_ip | Private IP of instance. |
151+
| public\_ip | Public IP of instance \(or EIP\). |
152+
| subnet\_id | The EC2 subnet ID. |
153+
| vpc\_security\_group\_ids | The associated security groups in non-default VPC. |
178154

179155

180156

@@ -207,4 +183,4 @@ At [CloudDrove][website], we offer expert guidance, implementation support and s
207183
[linkedin]: https://cpco.io/linkedin
208184
[twitter]: https://twitter.com/clouddrove/
209185
[email]: https://clouddrove.com/contact-us.html
210-
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
186+
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=

README.yaml

+35-4
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ include:
3232

3333
# How to use this project
3434
usage : |-
35-
### Simple Example
36-
Here is an example of how you can use this module in your inventory structure:
35+
Here is examples of how you can use this module in your inventory structure:
36+
### Basic Example
3737
```hcl
3838
module "ec2" {
39-
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.5"
39+
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7"
4040
name = "ec2-instance"
4141
application = "clouddrove"
4242
environment = "test"
4343
label_order = ["environment", "application", "name"]
4444
instance_count = 2
4545
ami = "ami-08d658f84a6d84a80"
4646
instance_type = "t2.nano"
47-
key_name = module.keypair.name
4847
monitoring = false
4948
tenancy = "default"
5049
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
@@ -62,4 +61,36 @@ usage : |-
6261
dns_zone_id = "Z1XJD7SSBKXLC1"
6362
hostname = "ec2"
6463
}
64+
```
65+
66+
### Secure Example
67+
```hcl
68+
module "ec2" {
69+
source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7"
70+
name = "ec2-instance"
71+
application = "clouddrove"
72+
environment = "test"
73+
label_order = ["environment", "application", "name"]
74+
instance_count = 2
75+
ami = "ami-08d658f84a6d84a80"
76+
instance_type = "t2.nano"
77+
monitoring = false
78+
tenancy = "default"
79+
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
80+
subnet_ids = tolist(module.public_subnets.public_subnet_id)
81+
assign_eip_address = true
82+
associate_public_ip_address = true
83+
instance_profile_enabled = true
84+
iam_instance_profile = module.iam-role.name
85+
disk_size = 8
86+
ebs_optimized = false
87+
ebs_volume_enabled = true
88+
ebs_volume_type = "gp2"
89+
ebs_volume_size = 30
90+
encrypted = true
91+
kms_key_id = module.kms_key.key_arn
92+
instance_tags = { "snapshot" = true }
93+
dns_zone_id = "Z1XJD7SSBKXLC1"
94+
hostname = "ec2"
95+
}
6596
```

_example/example.tf _example/basic_example/example.tf

+10-11
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module "ssh" {
5050
label_order = ["environment", "application", "name"]
5151

5252
vpc_id = module.vpc.vpc_id
53-
allowed_ip = [module.vpc.vpc_cidr_block]
53+
allowed_ip = [module.vpc.vpc_cidr_block, "0.0.0.0/0"]
5454
allowed_ports = [22]
5555
}
5656

@@ -91,20 +91,20 @@ data "aws_iam_policy_document" "iam-policy" {
9191
}
9292
}
9393

94+
9495
module "ec2" {
95-
source = "./../"
96+
source = "./../../"
9697

9798
name = "ec2-instance"
9899
application = "clouddrove"
99100
environment = "test"
100101
label_order = ["environment", "application", "name"]
101102

102-
instance_count = 2
103-
ami = "ami-08d658f84a6d84a80"
104-
instance_type = "t2.nano"
105-
monitoring = false
106-
tenancy = "default"
107-
103+
instance_count = 2
104+
ami = "ami-08d658f84a6d84a80"
105+
instance_type = "t2.nano"
106+
monitoring = false
107+
tenancy = "default"
108108
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
109109
subnet_ids = tolist(module.public_subnets.public_subnet_id)
110110

@@ -121,7 +121,6 @@ module "ec2" {
121121
ebs_volume_size = 30
122122

123123
instance_tags = { "snapshot" = true }
124-
125-
dns_zone_id = "Z1XJD7SSBKXLC1"
126-
hostname = "ec2"
124+
dns_zone_id = "Z1XJD7SSBKXLC1"
125+
hostname = "ec2"
127126
}
File renamed without changes.

0 commit comments

Comments
 (0)