Open hirosakaki opened 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
I've done some initial investigation and I think I've tracked down the cause of this:
The properties cidrs
, ipv6_cidrs
, and cidr_list_aliases
are all set to Optional-Computed, however expandPortInfo()
reads them directly to get the desired state:
If they're not set, they'll evaluate to an empty slice, which doesn't necessarily match the AWS state or defaults (e.g. cidrs
and ipv6_cidrs
default to ["0.0.0.0/0"] and ["::/0"] respectively).
As such, they are considered by Terraform to be changing when they really aren't.
So, as a workaround, you can explicitly set those two properties on the resource e.g.
cidrs = ["0.0.0.0/0"]
ipv6_cidrs = ["::/0"]
cidr_list_aliases = []
I made the following settings but it didn't work.
resource "aws_lightsail_instance_public_ports" "example" {
instance_name = aws_lightsail_instance.example.name
port_info {
protocol = "all"
from_port = 0
to_port = 65535
cidrs = ["0.0.0.0/0"]
ipv6_cidrs = ["::/0"]
cidr_list_aliases = []
}
}
Isn't this problem caused by "-1" being returned even though the protocol setting is "all"?
This issue is causing many acceptance tests to fail when I was working on #37703.
One viable fix is to set these arguments to required and force users to provide a valid value, but it would break backward compatibility (not that it worked anyway).
For reference, the default value is dynamic based on the protocol:
protocol |
cidrs default value |
ipv6_cidrs default value |
---|---|---|
all |
["0.0.0.0/0"] |
["::/0"] |
icmp |
["0.0.0.0/0"] |
[] |
icmpv6 |
[] |
["::/0"] |
tcp |
["0.0.0.0/0"] |
["::/0"] |
udp |
["0.0.0.0/0"] |
["::/0"] |
Terraform Core Version
1.4.2
AWS Provider Version
4.60.0
Affected Resource(s)
aws_lightsail_instance_public_ports
Expected Behavior
No changes. Your infrastructure matches the configuration.
Actual Behavior
Plan: 1 to add, 0 to change, 1 to destroy.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
Execute the following command
terraform apply -auto-approve
Then execute the following command
terraform apply
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None