https://pulumi.com logo
#aws
Title
# aws
r

rough-pencil-74127

01/19/2024, 10:57 AM
Hello, I'm new to Pulumi and I have a question about importing existing hosted zones in Pulumi in Go. So I bought a domain name in AWS and I want to use the hosted zone that was generated. I used this command:
pulumi import aws:route53/zone:Zone example.xyz Z0243U76JHV73LKJH98TRS90
and I got this code
Copy code
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := route53.NewZone(ctx, "lis-dev.xyz", &route53.ZoneArgs{
			Comment: pulumi.String("HostedZone created by Route53 Registrar"),
			Name:    pulumi.String("example.xyz"),
		}, pulumi.Protect(true))
		if err != nil {
			return err
		}
		return nil
	})
}
I used it in my code, but when I want to deploy it (
pulumi up
) I get this error
Copy code
error: Preview failed: resource "urn:pulumi:xxx::yyy::aws:route53/zone:Zone::example.xyz" cannot be deleted
    because it is protected. To unprotect the resource, either remove the `protect` flag from the resource in your Pulumi program and run `pulumi up`, or use the command:
    `pulumi state unprotect 'urn:pulumi:xxx::yyy::aws:route53/zone:Zone::example.xyz'
So, I don't know if I have to delete the hosted zone, but it would mean that all the records will be lost. Anyone can help me ?
g

great-zebra-31498

01/19/2024, 1:43 PM
I noticed that importing with protection was too problematic for me. Import didn't fetch all the data and
pulumi up
would want to update some attributes during next run. I'd suggest to unprotect imported resources and check changes with
pulumi preview --diff
first, before running
pulumi up
Later, when your infrastructure is stable and there are no changes in preview I'd consider protecting crucial resources.
https://www.pulumi.com/docs/cli/commands/pulumi_import/ when importing you can set
--protect=false
flag
2 Views