-
Notifications
You must be signed in to change notification settings - Fork 18
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
ForceNew on a property of an array type doesn't cause replacement when elements of array change #45
Comments
@lukehoban Is this still an issue? |
Yes. import * as aws from "@pulumi/aws";
import * as awsinfra from "@pulumi/cloud-aws/infrastructure";
let network = new awsinfra.Network("net", {
numberOfAvailabilityZones: 2,
privateSubnets: true,
});
let lb = new aws.elasticloadbalancingv2.LoadBalancer("foo", {
loadBalancerType: "network",
subnetMapping: [{
// Change this to `network.subnetIds[1]`
subnetId: network.subnetIds[0],
}],
}); After doing an initial
Note that:
|
Just hit this again - made a change to a nested property in an input which should have triggered replacement, but it only did an update (which didn't behave correctly at all - even though it succeeded). This is a pretty serious (and subtle) bug. |
These are the ResourceAttrDiffs we get back from Terraform.Diff:
|
I wonder if this is a bug in the way we're doing set diffing. For instance, as far as I know, we do nothing with the custom I'm curious what @pgavlin thinks so long as he isn't too busy drikker øl. |
This is a bug in some combination of the Terraform AWS provider and Terraform's set diffing logic.
First, recall how "subnet_mapping": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"subnet_id": {
Type: schema.TypeString,
Required: true,
},
"allocation_id": {
Type: schema.TypeString,
Optional: true,
},
},
},
Set: func(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["subnet_id"].(string)))
if m["allocation_id"] != "" {
buf.WriteString(fmt.Sprintf("%s-", m["allocation_id"].(string)))
}
return hashcode.String(buf.String())
},
}, (ref) Specifically: a So... if we change Compare that to the logic immediately afterward when the element is a |
Sent hashicorp/terraform-provider-aws#4086 upstream. |
The `subnetMappings` property does not correctly handle changes, but the `subnets` property does - and supports the same use cases we need. Workaround for pulumi/pulumi-terraform#45.
The `subnetMappings` property does not correctly handle changes, but the `subnets` property does - and supports the same use cases we need. Workaround for pulumi/pulumi-terraform#45.
This is done now in pulumi/pulumi-cloud#451. Given that - I think we are okay to close this out now. Thanks @mmdriley for tracking things down here. |
The
subnet_mapping
property ofresource_aws_lb
is markedForceNew: true
. It is an array of structs. When the array changes though, it does not trigger a replacement of the Load Balancer, instead just trying to do a modification (which looks like it succeeds, but actually doesn't do anything in the Terraform provider since it doesn't expect to have to try to do this modification in place).The text was updated successfully, but these errors were encountered: