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

Added use case for availability_zones in autoscaling docs #7615

Merged
merged 2 commits into from
Aug 31, 2021

Conversation

unixninja92
Copy link
Contributor

Changes proposed in this pull request:

  • Fix docs to include new use case for the availability_zones parameter in the auto scaling group resource

@ghost ghost added service/autoscaling Issues and PRs that pertain to the autoscaling service. size/XS Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. labels Feb 20, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @unixninja92 👋 Thanks for submitting this. Could you please provide us with some additional context about this note? e.g. relevant AWS documentation or an example Terraform configuration and error? Thanks.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 22, 2019
@unixninja92
Copy link
Contributor Author

yeah, when you try and create an auto scaling group based on a launch template that attaches a specific ENI via id, if you read the current docs you assume you need to set vpc_zone_identifier in the asg config rather than availability_zones becasue of the note that the latter is only for ec2-classic. When running

resource "aws_network_interface" "XXXXX" {
  subnet_id = "${data.terraform_remote_state.vpc.public-subnet}"
  security_groups = ["${aws_security_group.XXXXX.id}"]
  source_dest_check = false
}

resource "aws_launch_template" "XXXXX" {
    name = "XXXXX"
    ebs_optimized = true
    image_id = "ami-XXXXX"
    instance_type               = "m5.large"
    key_name = "XXXXX"
    network_interfaces {
      network_interface_id = "${aws_network_interface.XXXXX.id}"
    }
    user_data            = "${base64encode(local.XXXXX-userdata)}"
}
resource "aws_autoscaling_group" "XXXXX" {
  name                 = "XXXXX"
  launch_template {
    id = "${aws_launch_template.XXXXX.id}"
    version = "${aws_launch_template.XXXXX.latest_version}"
  }
  min_size             = 1
  desired_capacity     = 1
  max_size             = 1
  vpc_zone_identifier = ["${data.terraform_remote_state.vpc.public-subnet}"]
}

you get the following error:
Invalid details specified: You must use a valid fully-formed launch template. A network interface may not specify both a network interface ID and a subnet
This is because the subnet is selected based on where the ENI is and they don't want you defining this twice. When neither vpc_zone_identifier or availability_zones is specified you get an error saying you need to set one of them (don't have the exact error message on hand).

I opened a support ticket with aws about this as I was also having this issue with their web console. They confirmed that it was a bug in the web console, but gave me cli commands that work (which sets availability_zones instead of vpc_zone_identifier) and also noted that their cli docs do not currently cover this use case. I believe fixing this is now on their internal roadmap.

To summarize, switching
vpc_zone_identifier = ["${data.terraform_remote_state.vpc.public-subnet}"]
to
availability_zones = ["${data.aws_subnet.XXXXX-subnet.availability_zone}"]
makes it work but is not reflected in current docs.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 22, 2019
@aeschright aeschright requested a review from a team June 26, 2019 00:48
@rflume
Copy link

rflume commented May 18, 2020

They confirmed that it was a bug in the web console, but gave me cli commands that work [...]

Hey, could you provide that command maybe? I'm having the same issue currently but try not to use terraform to create the ASG.

@unixninja92
Copy link
Contributor Author

They confirmed that it was a bug in the web console, but gave me cli commands that work [...]

Hey, could you provide that command maybe? I'm having the same issue currently but try not to use terraform to create the ASG.

aws autoscaling create-auto-scaling-group --auto-scaling-group-name <NAME> --min-size 1 --max-size 1 --launch-template LaunchTemplateId=<TemplateID> --availability-zones <az-name>

Base automatically changed from master to main January 23, 2021 00:55
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:55
@breathingdust breathingdust merged commit 8075cb4 into hashicorp:main Aug 31, 2021
@github-actions github-actions bot added this to the v3.57.0 milestone Aug 31, 2021
@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This functionality has been released in v3.57.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. service/autoscaling Issues and PRs that pertain to the autoscaling service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants