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

IPv6 prefix and address count specified in same API request resulting in error #23203

Open
dr-yd opened this issue Feb 15, 2022 · 4 comments
Open
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@dr-yd
Copy link

dr-yd commented Feb 15, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v1.1.5
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v4.0.0

Affected Resource(s)

  • aws_network_interface

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_vpc" "temp" {
  cidr_block                       = "10.1.2.0/24"
  assign_generated_ipv6_cidr_block = true
}

resource "aws_subnet" "temp" {
  vpc_id                          = aws_vpc.temp.id
  cidr_block                      = "10.1.2.0/25"
  ipv6_cidr_block                 = cidrsubnet(aws_vpc.temp.ipv6_cidr_block, 8, 1)
  assign_ipv6_address_on_creation = true
}

resource "aws_network_interface" "temp" {
  subnet_id          = aws_subnet.temp.id
  ipv6_address_count = 1
  ipv6_prefix_count  = 1
}

Debug Output

Debug output is available upon request directly to the team.

Expected Behavior

A network interface with both an IPv6 address and an IPv6 prefix is created.

Actual Behavior

│ Error: error creating EC2 Network Interface: InvalidParameterValue: You can specify one and only one of ipv6AddressCount or ipv6Addresses or ipv6Prefixes or ipv6PrefixCount.
│       status code: 400, request id: ed814c88-ec09-46fa-b0b8-c4b610b02690
│
│   with aws_network_interface.temp,
│   on t.tf line 13, in resource "aws_network_interface" "temp":
│   13: resource "aws_network_interface" "temp" {

Presumably, the provider would have to mask that API requirement my making two separate calls. If one or the other is set, then the second setting is added and Terraform is re-run, the interface ends up as desired. This is impractical in many codebases, e. g. when a module creates the interface.

Steps to Reproduce

  1. terraform apply

Important Factoids

The error message's grammar was badly garbled using provider 3.x a few days ago, which likely means that this is a moving target.

References

None found.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 15, 2022
@ewbankkit ewbankkit added the bug Addresses a defect in current functionality. label Feb 15, 2022
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Feb 15, 2022
@dirk39
Copy link
Contributor

dirk39 commented Jul 13, 2022

Hi @dr-yd, I've tried to replicate the issue via CLI and this is the error I've got:

An error occurred (InvalidParameterValue) when calling the CreateNetworkInterface operation: You can specify one and only one of ipv6AddressCount or ipv6Addresses or ipv6Prefixes or ipv6PrefixCount.

IMHO we should add the conflictWith attribute for those fields. What do you think?

@dr-yd
Copy link
Author

dr-yd commented Jul 13, 2022

IMO, these fields should definitely not conflict with each other, that would make something that is actually feasible with the API impossible to implement with Terraform! As described in the issue, running Terraform twice and adding the parameters one after another does work and results in the desired outcome. I don't know if there are any internal guidelines on how to handle things like that but like I said above, making two separate API calls would probably be the most seamless user experience.

@mmerickel
Copy link

This is quite an annoying issue in the AWS api and it would be great if terraform could work around it by invoking the api multiple times. It is perfectly valid to assign prefixes after the fact to an interface, but it's not possible to mix/match everything into a single create-network-interface invocation.

@mmerickel
Copy link

mmerickel commented Oct 26, 2022

I guess to be more helpful, in my example I was trying to do a slightly different combination of fields from OP but same issue/error. Note it's not using the count args at all, and that I can create an ENI like this manually via clickops in the console, just seemingly not all at once from a single call to create-network-interface:

resource "aws_network_interface" "this" {
  subnet_id         = aws_subnet.this.id
  security_groups   = [aws_security_group.instance.id]

  private_ips    = [local.private_ip]
  ipv6_addresses = [local.ipv6_address]
  ipv6_prefixes  = local.ipv6_prefixes
}

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/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

5 participants