[英]Pulumi - How can I remove imported resources from my stack without deleting them from aws?
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
:如果我尝试从我的代码中删除资源的引用,我会在运行
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 Slack 社区频道中所回答的那样,可以使用以下命令:
pulumi state delete <urn>
This will remove the reference from your state file but not from aws.这将从您的 state 文件中删除引用,但不会从 aws 中删除。
Also, if the resource is protected you'll first have to unprotect it or run the above command with the flag --force
.此外,如果资源受到保护,您首先必须取消保护它或使用标志运行上述命令
--force
。
For "bulkier" operations, you can export the stack as a JSON, delete the resources and import it back in ( docs ):对于“更大”的操作,您可以将堆栈导出为 JSON,删除资源并将其重新导入( 文档):
# Get the current stack as json:
pulumi stack export --file stack.json
# Delete what you don't want from your stack file and then:
pulumi stack import --file stack.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.