Skip to content

Instantly share code, notes, and snippets.

@dcaba
Created April 5, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcaba/d2f19f74dd9646f121d20d206bc4bb56 to your computer and use it in GitHub Desktop.
Save dcaba/d2f19f74dd9646f121d20d206bc4bb56 to your computer and use it in GitHub Desktop.
Pulumi DeleteBeforeReplace not working
package main
import (
"time"
"github.com/pulumi/pulumi-gcp/sdk/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
const instancePrefix = "remove-me-when-upgrading"
staticIP, err := compute.NewAddress(ctx, instancePrefix+"-ip", &compute.AddressArgs{})
instanceConfig := &compute.InstanceArgs{
MachineType: "f1-micro",
BootDisk: map[string]interface{}{
"initializeParams": map[string]string{
"image": "ubuntu-os-cloud/ubuntu-minimal-1804-bionic-v20190403",
},
},
MetadataStartupScript: "echo " + time.Now().String(),
AllowStoppingForUpdate: true,
NetworkInterfaces: []interface{}{
map[string]interface{}{
"network": "default",
"accessConfigs": []map[string]interface{}{
map[string]interface{}{
"natIp": staticIP.Address(),
},
},
},
},
}
_, err = compute.NewInstance(ctx, instancePrefix, instanceConfig, pulumi.ResourceOpt{
DeleteBeforeReplace: true,
})
return err
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment