I don't see any options in the documentation on how to delete imported resources from my stack. If I try to remove the resource's reference from my code I get the following error when running pulumi up
:
error: Preview failed: refusing to delete protected resource 'urn:pulumi:dev::my-cloud-infrastructure::aws:iam/instanceProfile:InstanceProfile::EC2CodeDeploy'
As answered in the Pulumi Slack community channel, one can use the command:
pulumi state delete <urn>
This will remove the reference from your state file but not from aws.
Also, if the resource is protected you'll first have to unprotect it or run the above command with the flag --force
.