Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Importing aws_autoscaling_group does not set defaults #39308

Open
flostadler opened this issue Sep 13, 2024 · 3 comments
Open

[Bug]: Importing aws_autoscaling_group does not set defaults #39308

flostadler opened this issue Sep 13, 2024 · 3 comments
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.

Comments

@flostadler
Copy link
Contributor

Terraform Core Version

1.5.7

AWS Provider Version

5.67.0

Affected Resource(s)

  • aws_autoscaling_group

Expected Behavior

Importing an ASG and then running terraform apply shows changes to the following properties:

  • force_delete
  • force_delete_warm_pool
  • ignore_failed_scaling_activities
  • wait_for_capacity_timeout

This is caused by the import not setting the default values for those props.

Actual Behavior

When importing an ASG and running terrform apply afterwards without modifications it should show no change.

The import should set defaults for the following properties:

  • force_delete
  • force_delete_warm_pool
  • ignore_failed_scaling_activities
  • wait_for_capacity_timeout

The root cause for this seems to be that the Read method of the resource doesn't set those attributes.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

data "aws_ami" "al2023" {
  owners      = ["amazon"]
  most_recent = true

  filter {
    name   = "name"
    values = ["al2023-ami-2023.*-kernel-*-x86_64"]
  }
}

resource "aws_launch_template" "example" {
  name          = "example"
  image_id      = data.aws_ami.al2023.id
  instance_type = "t2.micro"
}

resource "aws_autoscaling_group" "other" {
  availability_zones       = ["us-west-2a"]
  desired_capacity         = 1
  max_size                 = 1
  min_size                 = 1
  name                     = "test-asg"

  launch_template {
    id      = aws_launch_template.example.id
    version = "$Latest"
  }
}

output "asg_name" {
  value = aws_autoscaling_group.other.name
}

Steps to Reproduce

  • terraform apply
  • terraform state rm aws_autoscaling_group.other
  • terraform import aws_autoscaling_group.other "test-asg"

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@flostadler flostadler added the bug Addresses a defect in current functionality. label Sep 13, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. labels Sep 13, 2024
@rulatir
Copy link

rulatir commented Sep 13, 2024

The import should set the default values for these props only if AWS explicitly documents and bindingly promises what "Default" (in the sense of the "Default" option being selected in the respective select widget in AWS console) means, AND that promise is of this exact form: »"Default" means <this specific default value>«.

If there is no such guarantee of specific value because it is not documented at all, or the meaning of "Default" is given as a formula involving other variables, or as "it depends", "inherit from parent resource" or whatever, then terraform MUST treat "Default" as "Auto", and it MUST represent and handle (i.e. correctly import and apply) that precise intention, which is semantically distinct from specifying any fixed value.

@justinretzolk
Copy link
Member

Related #10334

@justinretzolk justinretzolk removed service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Projects
None yet
Development

No branches or pull requests

3 participants