Skip to content

Commit 97ea2bf

Browse files
authored
chore: Added example with ignore_ami_changes (#340)
1 parent 7a9c37b commit 97ea2bf

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.77.3
3+
rev: v1.81.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

examples/complete/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Note that this example may create resources which can cost money. Run `terraform
3535
| <a name="module_ec2_complete"></a> [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a |
3636
| <a name="module_ec2_cpu_options"></a> [ec2\_cpu\_options](#module\_ec2\_cpu\_options) | ../../ | n/a |
3737
| <a name="module_ec2_disabled"></a> [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a |
38+
| <a name="module_ec2_ignore_ami_changes"></a> [ec2\_ignore\_ami\_changes](#module\_ec2\_ignore\_ami\_changes) | ../../ | n/a |
3839
| <a name="module_ec2_metadata_options"></a> [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a |
3940
| <a name="module_ec2_multiple"></a> [ec2\_multiple](#module\_ec2\_multiple) | ../../ | n/a |
4041
| <a name="module_ec2_network_interface"></a> [ec2\_network\_interface](#module\_ec2\_network\_interface) | ../../ | n/a |
@@ -44,7 +45,7 @@ Note that this example may create resources which can cost money. Run `terraform
4445
| <a name="module_ec2_t3_unlimited"></a> [ec2\_t3\_unlimited](#module\_ec2\_t3\_unlimited) | ../../ | n/a |
4546
| <a name="module_ec2_targeted_capacity_reservation"></a> [ec2\_targeted\_capacity\_reservation](#module\_ec2\_targeted\_capacity\_reservation) | ../../ | n/a |
4647
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
47-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 4.0 |
48+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
4849

4950
## Resources
5051

@@ -85,6 +86,7 @@ No inputs.
8586
| <a name="output_ec2_complete_public_ip"></a> [ec2\_complete\_public\_ip](#output\_ec2\_complete\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached |
8687
| <a name="output_ec2_complete_root_block_device"></a> [ec2\_complete\_root\_block\_device](#output\_ec2\_complete\_root\_block\_device) | Root block device information |
8788
| <a name="output_ec2_complete_tags_all"></a> [ec2\_complete\_tags\_all](#output\_ec2\_complete\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block |
89+
| <a name="output_ec2_ignore_ami_changes_ami"></a> [ec2\_ignore\_ami\_changes\_ami](#output\_ec2\_ignore\_ami\_changes\_ami) | The AMI of the instance (ignore\_ami\_changes = true) |
8890
| <a name="output_ec2_multiple"></a> [ec2\_multiple](#output\_ec2\_multiple) | The full output of the `ec2_module` module |
8991
| <a name="output_ec2_spot_instance_arn"></a> [ec2\_spot\_instance\_arn](#output\_ec2\_spot\_instance\_arn) | The ARN of the instance |
9092
| <a name="output_ec2_spot_instance_capacity_reservation_specification"></a> [ec2\_spot\_instance\_capacity\_reservation\_specification](#output\_ec2\_spot\_instance\_capacity\_reservation\_specification) | Capacity reservation specification of the instance |

examples/complete/main.tf

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,32 @@ module "ec2_t3_unlimited" {
154154
tags = local.tags
155155
}
156156

157-
158157
module "ec2_disabled" {
159158
source = "../../"
160159

161160
create = false
162161
}
163162

163+
################################################################################
164+
# EC2 Module - with ignore AMI changes
165+
################################################################################
166+
167+
module "ec2_ignore_ami_changes" {
168+
source = "../../"
169+
170+
name = local.name
171+
172+
ignore_ami_changes = true
173+
174+
ami = data.aws_ami.amazon_linux.id
175+
instance_type = "t2.micro"
176+
availability_zone = element(module.vpc.azs, 0)
177+
subnet_id = element(module.vpc.private_subnets, 0)
178+
vpc_security_group_ids = [module.security_group.security_group_id]
179+
180+
tags = local.tags
181+
}
182+
164183
################################################################################
165184
# EC2 Module - multiple instances with `for_each`
166185
################################################################################
@@ -409,7 +428,7 @@ module "ec2_cpu_options" {
409428

410429
module "vpc" {
411430
source = "terraform-aws-modules/vpc/aws"
412-
version = "~> 4.0"
431+
version = "~> 5.0"
413432

414433
name = local.name
415434
cidr = local.vpc_cidr

examples/complete/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ output "ec2_t3_unlimited_tags_all" {
181181
value = module.ec2_t3_unlimited.tags_all
182182
}
183183

184+
# EC2 with ignore AMI changes
185+
output "ec2_ignore_ami_changes_ami" {
186+
description = "The AMI of the instance (ignore_ami_changes = true)"
187+
value = module.ec2_ignore_ami_changes.ami
188+
}
189+
184190
# EC2 Multiple
185191
output "ec2_multiple" {
186192
description = "The full output of the `ec2_module` module"

0 commit comments

Comments
 (0)