From 49037d6b468172a96861f07d0d423bb2db951aae Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Thu, 15 Jun 2023 15:05:47 +0200 Subject: [PATCH] chore: Added example with ignore_ami_changes --- .pre-commit-config.yaml | 2 +- examples/complete/README.md | 4 +++- examples/complete/main.tf | 23 +++++++++++++++++++++-- examples/complete/outputs.tf | 6 ++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e940bf7d..e79e67b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.77.3 + rev: v1.81.0 hooks: - id: terraform_fmt - id: terraform_wrapper_module_for_each diff --git a/examples/complete/README.md b/examples/complete/README.md index 18d25d8e..9fa60b35 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -35,6 +35,7 @@ Note that this example may create resources which can cost money. Run `terraform | [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a | | [ec2\_cpu\_options](#module\_ec2\_cpu\_options) | ../../ | n/a | | [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a | +| [ec2\_ignore\_ami\_changes](#module\_ec2\_ignore\_ami\_changes) | ../../ | n/a | | [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a | | [ec2\_multiple](#module\_ec2\_multiple) | ../../ | n/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 | [ec2\_t3\_unlimited](#module\_ec2\_t3\_unlimited) | ../../ | n/a | | [ec2\_targeted\_capacity\_reservation](#module\_ec2\_targeted\_capacity\_reservation) | ../../ | n/a | | [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 | -| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 4.0 | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | ## Resources @@ -85,6 +86,7 @@ No inputs. | [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 | | [ec2\_complete\_root\_block\_device](#output\_ec2\_complete\_root\_block\_device) | Root block device information | | [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 | +| [ec2\_ignore\_ami\_changes\_ami](#output\_ec2\_ignore\_ami\_changes\_ami) | The AMI of the instance (ignore\_ami\_changes = true) | | [ec2\_multiple](#output\_ec2\_multiple) | The full output of the `ec2_module` module | | [ec2\_spot\_instance\_arn](#output\_ec2\_spot\_instance\_arn) | The ARN of the instance | | [ec2\_spot\_instance\_capacity\_reservation\_specification](#output\_ec2\_spot\_instance\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 0cdd484f..0d0120ab 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -154,13 +154,32 @@ module "ec2_t3_unlimited" { tags = local.tags } - module "ec2_disabled" { source = "../../" create = false } +################################################################################ +# EC2 Module - with ignore AMI changes +################################################################################ + +module "ec2_ignore_ami_changes" { + source = "../../" + + name = local.name + + ignore_ami_changes = true + + ami = data.aws_ami.amazon_linux.id + instance_type = "t2.micro" + availability_zone = element(module.vpc.azs, 0) + subnet_id = element(module.vpc.private_subnets, 0) + vpc_security_group_ids = [module.security_group.security_group_id] + + tags = local.tags +} + ################################################################################ # EC2 Module - multiple instances with `for_each` ################################################################################ @@ -409,7 +428,7 @@ module "ec2_cpu_options" { module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "~> 4.0" + version = "~> 5.0" name = local.name cidr = local.vpc_cidr diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 14272480..1ce36b82 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -181,6 +181,12 @@ output "ec2_t3_unlimited_tags_all" { value = module.ec2_t3_unlimited.tags_all } +# EC2 with ignore AMI changes +output "ec2_ignore_ami_changes_ami" { + description = "The AMI of the instance (ignore_ami_changes = true)" + value = module.ec2_ignore_ami_changes.ami +} + # EC2 Multiple output "ec2_multiple" { description = "The full output of the `ec2_module` module"