Skip to content

Issue with plan if not capacity reservation provided  #286

Closed
@savroman

Description

@savroman

Description

Running terraform plan cased the issue

If your request is for a new feature, please use the Feature request template.

  • ✋ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Done! But not helps.

Versions

  • Module version: 4.1.3
  • Terraform version: 1.2.6
  • Provider version(s): 4.23.0

Reproduction Code [Required]

module "ec2_data" {
  # https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws/latest
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = "~> 4.0"
  # insert the 10 required variables here
  create = true

  name                        = "${local.pre-fix}"
  ami                         = data.aws_ssm_parameter.ubuntu_latest_ami_arm64.value
  instance_type               = "t4g.micro"
  cpu_credits                 = "unlimited"
  subnet_id                   = module.vpc.public_subnets[0]
  vpc_security_group_ids      = [aws_security_group.ssh.id]
  associate_public_ip_address = true
  ebs_optimized               = true
  iam_instance_profile        = aws_iam_instance_profile.ec2.name
  key_name                    = aws_key_pair.ec2.key_name
  user_data                   = null
  disable_api_termination     = true
  monitoring                  = false
  root_block_device = [
    {
      volume_type = "gp2"
      volume_size = 50
    }
  ]
  
}

Steps to reproduce the behavior:
terraform init
terraform plan

Expected behavior

plan output

Actual behavior

 Error: Invalid combination of arguments
│ 
│   with module.ec2_data.aws_instance.this[0],
│   on .terraform/modules/ec2_data/main.tf line 7, in resource "aws_instance" "this":
│    7: resource "aws_instance" "this" {
│ 
│ "capacity_reservation_specification.0.capacity_reservation_target": one of
│ `capacity_reservation_specification.0.capacity_reservation_preference,capacity_reservation_specification.0.capacity_reservation_target`
│ must be specified

Terminal Output Screenshot(s)

Additional context

Downgrade to 4.1.2 fixes the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions