Skip to content

Commit e6d2f70

Browse files
authored
Tags should be possible to override (fixed #53) (#66)
1 parent b9a4c55 commit e6d2f70

File tree

6 files changed

+56
-59
lines changed

6 files changed

+56
-59
lines changed

README.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -86,57 +86,56 @@ data "aws_ami" "ubuntu-xenial" {
8686
* Changes in `ebs_block_device` argument will be ignored. Use [aws_volume_attachment](https://www.terraform.io/docs/providers/aws/r/volume_attachment.html) resource to attach and detach volumes from AWS EC2 instances. See [this example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/volume-attachment).
8787

8888
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
89-
9089
## Inputs
9190

9291
| Name | Description | Type | Default | Required |
9392
|------|-------------|:----:|:-----:|:-----:|
94-
| ami | ID of AMI to use for the instance | string | - | yes |
95-
| associate_public_ip_address | If true, the EC2 instance will have associated public IP address | string | `false` | no |
96-
| cpu_credits | The credit option for CPU usage (unlimited or standard) | string | `standard` | no |
97-
| disable_api_termination | If true, enables EC2 Instance Termination Protection | string | `false` | no |
98-
| ebs_block_device | Additional EBS block devices to attach to the instance | string | `<list>` | no |
99-
| ebs_optimized | If true, the launched EC2 instance will be EBS-optimized | string | `false` | no |
100-
| ephemeral_block_device | Customize Ephemeral (also known as Instance Store) volumes on the instance | string | `<list>` | no |
101-
| iam_instance_profile | The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. | string | `` | no |
102-
| instance_count | Number of instances to launch | string | `1` | no |
103-
| instance_initiated_shutdown_behavior | Shutdown behavior for the instance | string | `` | no |
104-
| instance_type | The type of instance to start | string | - | yes |
105-
| ipv6_address_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | string | `0` | no |
106-
| ipv6_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | string | `<list>` | no |
107-
| key_name | The key name to use for the instance | string | `` | no |
108-
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | string | `false` | no |
109-
| name | Name to be used on all resources as prefix | string | - | yes |
110-
| network_interface | Customize network interfaces to be attached at instance boot time | string | `<list>` | no |
111-
| placement_group | The Placement Group to start the instance in | string | `` | no |
112-
| private_ip | Private IP address to associate with the instance in a VPC | string | `` | no |
113-
| root_block_device | Customize details about the root block device of the instance. See Block Devices below for details | string | `<list>` | no |
114-
| 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. | string | `true` | no |
115-
| subnet_id | The VPC Subnet ID to launch in | string | - | yes |
116-
| tags | A mapping of tags to assign to the resource | string | `<map>` | no |
117-
| tenancy | The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host. | string | `default` | no |
118-
| user_data | The user data to provide when launching the instance | string | `` | no |
119-
| volume_tags | A mapping of tags to assign to the devices created by the instance at launch time | string | `<map>` | no |
120-
| vpc_security_group_ids | A list of security group IDs to associate with | list | - | yes |
93+
| ami | ID of AMI to use for the instance | string | n/a | yes |
94+
| associate\_public\_ip\_address | If true, the EC2 instance will have associated public IP address | string | `"false"` | no |
95+
| cpu\_credits | The credit option for CPU usage (unlimited or standard) | string | `"standard"` | no |
96+
| disable\_api\_termination | If true, enables EC2 Instance Termination Protection | string | `"false"` | no |
97+
| ebs\_block\_device | Additional EBS block devices to attach to the instance | list | `<list>` | no |
98+
| ebs\_optimized | If true, the launched EC2 instance will be EBS-optimized | string | `"false"` | no |
99+
| ephemeral\_block\_device | Customize Ephemeral (also known as Instance Store) volumes on the instance | list | `<list>` | no |
100+
| iam\_instance\_profile | The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. | string | `""` | no |
101+
| instance\_count | Number of instances to launch | string | `"1"` | no |
102+
| instance\_initiated\_shutdown\_behavior | Shutdown behavior for the instance | string | `""` | no |
103+
| instance\_type | The type of instance to start | string | n/a | yes |
104+
| ipv6\_address\_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | string | `"0"` | no |
105+
| ipv6\_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | list | `<list>` | no |
106+
| key\_name | The key name to use for the instance | string | `""` | no |
107+
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | string | `"false"` | no |
108+
| name | Name to be used on all resources as prefix | string | n/a | yes |
109+
| network\_interface | Customize network interfaces to be attached at instance boot time | list | `<list>` | no |
110+
| placement\_group | The Placement Group to start the instance in | string | `""` | no |
111+
| private\_ip | Private IP address to associate with the instance in a VPC | string | `""` | no |
112+
| root\_block\_device | Customize details about the root block device of the instance. See Block Devices below for details | list | `<list>` | no |
113+
| 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. | string | `"true"` | no |
114+
| subnet\_id | The VPC Subnet ID to launch in | string | n/a | yes |
115+
| tags | A mapping of tags to assign to the resource | map | `<map>` | no |
116+
| tenancy | The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host. | string | `"default"` | no |
117+
| user\_data | The user data to provide when launching the instance | string | `""` | no |
118+
| volume\_tags | A mapping of tags to assign to the devices created by the instance at launch time | map | `<map>` | no |
119+
| vpc\_security\_group\_ids | A list of security group IDs to associate with | list | n/a | yes |
121120

122121
## Outputs
123122

124123
| Name | Description |
125124
|------|-------------|
126-
| availability_zone | List of availability zones of instances |
127-
| credit_specification | List of credit specification of instances |
125+
| availability\_zone | List of availability zones of instances |
126+
| credit\_specification | List of credit specification of instances |
128127
| id | List of IDs of instances |
129-
| key_name | List of key names of instances |
130-
| network_interface_id | List of IDs of the network interface of instances |
131-
| primary_network_interface_id | List of IDs of the primary network interface of instances |
132-
| private_dns | List of private DNS names assigned to the instances. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC |
133-
| private_ip | List of private IP addresses assigned to the instances |
134-
| public_dns | List of public DNS names assigned to the instances. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC |
135-
| public_ip | List of public IP addresses assigned to the instances, if applicable |
136-
| security_groups | List of associated security groups of instances |
137-
| subnet_id | List of IDs of VPC subnets of instances |
128+
| key\_name | List of key names of instances |
129+
| network\_interface\_id | List of IDs of the network interface of instances |
130+
| primary\_network\_interface\_id | List of IDs of the primary network interface of instances |
131+
| private\_dns | List of private DNS names assigned to the instances. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC |
132+
| private\_ip | List of private IP addresses assigned to the instances |
133+
| public\_dns | List of public DNS names assigned to the instances. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC |
134+
| public\_ip | List of public IP addresses assigned to the instances, if applicable |
135+
| security\_groups | List of associated security groups of instances |
136+
| subnet\_id | List of IDs of VPC subnets of instances |
138137
| tags | List of tags of instances |
139-
| vpc_security_group_ids | List of associated security groups of instances, if running in non-default VPC |
138+
| vpc\_security\_group\_ids | List of associated security groups of instances, if running in non-default VPC |
140139

141140
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
142141

examples/basic/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@ $ terraform apply
1919
Note that this example may create resources which can cost money. Run `terraform destroy` when you don't need these resources.
2020

2121
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
22-
2322
## Outputs
2423

2524
| Name | Description |
2625
|------|-------------|
27-
| credit_specification | Credit specification of EC2 instance (empty list for not t2 instance types) |
28-
| credit_specification_t2_unlimited | Credit specification of t2-type EC2 instance |
26+
| credit\_specification | Credit specification of EC2 instance (empty list for not t2 instance types) |
27+
| credit\_specification\_t2\_unlimited | Credit specification of t2-type EC2 instance |
2928
| ids | List of IDs of instances |
30-
| ids_t2 | List of IDs of t2-type instances |
31-
| instance_id | EC2 instance ID |
32-
| instance_public_dns | Public DNS name assigned to the EC2 instance |
33-
| public_dns | List of public DNS names assigned to the instances |
29+
| ids\_t2 | List of IDs of t2-type instances |
30+
| instance\_id | EC2 instance ID |
31+
| instance\_public\_dns | Public DNS name assigned to the EC2 instance |
32+
| public\_dns | List of public DNS names assigned to the instances |
3433
| tags | List of tags |
35-
| vpc_security_group_ids | List of VPC security group ids assigned to the instances |
34+
| vpc\_security\_group\_ids | List of VPC security group ids assigned to the instances |
3635

3736
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/basic/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ data "aws_ami" "amazon_linux" {
3434
}
3535

3636
module "security_group" {
37-
source = "terraform-aws-modules/security-group/aws"
38-
version = "2.7.0"
37+
source = "terraform-aws-modules/security-group/aws"
38+
version = "2.7.0"
3939

4040
name = "example"
4141
description = "Security group for example usage with EC2 instance"

examples/volume-attachment/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ $ terraform apply
1919
Note that this example may create resources which can cost money. Run `terraform destroy` when you don't need these resources.
2020

2121
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
22-
2322
## Outputs
2423

2524
| Name | Description |
2625
|------|-------------|
27-
| ebs_volume_attachment_id | The volume ID |
28-
| ebs_volume_attachment_instance_id | The instance ID |
29-
| instance_id | EC2 instance ID |
30-
| instance_public_dns | Public DNS name assigned to the EC2 instance |
26+
| ebs\_volume\_attachment\_id | The volume ID |
27+
| ebs\_volume\_attachment\_instance\_id | The instance ID |
28+
| instance\_id | EC2 instance ID |
29+
| instance\_public\_dns | Public DNS name assigned to the EC2 instance |
3130

3231
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/volume-attachment/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ data "aws_ami" "amazon_linux" {
3434
}
3535

3636
module "security_group" {
37-
source = "terraform-aws-modules/security-group/aws"
38-
version = "2.7.0"
37+
source = "terraform-aws-modules/security-group/aws"
38+
version = "2.7.0"
3939

4040
name = "example"
4141
description = "Security group for example usage with EC2 instance"

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ resource "aws_instance" "this" {
3434
placement_group = "${var.placement_group}"
3535
tenancy = "${var.tenancy}"
3636

37-
tags = "${merge(var.tags, map("Name", var.instance_count > 1 ? format("%s-%d", var.name, count.index+1) : var.name))}"
37+
tags = "${merge(map("Name", var.instance_count > 1 ? format("%s-%d", var.name, count.index+1) : var.name), var.tags)}"
3838

3939
lifecycle {
4040
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:
@@ -77,7 +77,7 @@ resource "aws_instance" "this_t2" {
7777
cpu_credits = "${var.cpu_credits}"
7878
}
7979

80-
tags = "${merge(var.tags, map("Name", var.instance_count > 1 ? format("%s-%d", var.name, count.index+1) : var.name))}"
80+
tags = "${merge(map("Name", var.instance_count > 1 ? format("%s-%d", var.name, count.index+1) : var.name), var.tags)}"
8181

8282
lifecycle {
8383
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:

0 commit comments

Comments
 (0)