“orphan” 在 “cdk diff” 中的意思是什么?

huangapple go评论57阅读模式
英文:

What does "orphan" mean in the "cdk diff"?

问题

Sure, here is the translation of the provided text without the code:

"cdk diff 显示了以下差异,因为我正在删除一些服务。请注意,最后一行显示了 orphan。这是什么意思?即使在 cdk deploy 之后,它是否会继续占用空间。"

And here's the translation of the relevant code snippet:

const container = taskDefinition.addContainer("myServiceContainer", {
  image: "...",
  logging: ecs.LogDriver.awsLogs({
    streamPrefix: "myServiceContainer",
  }),
});
英文:

cdk diff shows the befow diff because I am removing some of the services. Notice that the last line shows orphan in the end. What does that mean? Will this continue to occupy space even after the cdk deploy.

[-] AWS::IAM::Role myServiceTask77c32c53ac6143bcb908adfc54ce2977/TaskRole myServiceTask77c32c53ac6143bcb908adfc54ce2977TaskRoleD0FE40D9 destroy
[-] AWS::ECS::TaskDefinition myServiceTask77c32c53ac6143bcb908adfc54ce2977 myServiceTask77c32c53ac6143bcb908adfc54ce29777B67982E destroy
[-] AWS::Logs::LogGroup myServiceTask77c32c53ac6143bcb908adfc54ce2977/myServiceContainer77c32c53ac6143bcb908adfc54ce2977/LogGroup myServiceTask77c32c53ac6143bcb908adfc54ce2977rmsisServiceContainer77c32c53ac6143bcb908adfc54ce2977LogGroupAC4EC700 orphan

Here is my relevant cdk code,

const container = taskDefinition.addContainer("myServiceContainer", {
  image: "...",
  logging: ecs.LogDriver.awsLogs({
    streamPrefix: "myServiceContainer",
  }),
});

答案1

得分: 0

它意味着这是一个将从CloudFormation中删除但在帐户中保留的资源。

ecs.LogDriver.awsLogs未提供logGroup: ILogGroup prop时,CDK会创建一个LogGroup。这个由CDK创建的LogGroup具有默认的Removal Policy,即RemovalPolicy.RETAIN。并且默认的RetentionDays设置为RetentionDays.TWO_YEARS。RETAIN行为将“孤立”资源:

> 这使用'Retain' DeletionPolicy,它将导致资源保留在帐户中,但从堆栈中孤立出来。

如果您想要CloudFormation进行清理,请使用RemovalPolicy.DESTROY将您自己的LogGroup传递给awsLogs

英文:

It means it is a resource that will be deleted from CloudFormation, but retained in the account.

When ecs.LogDriver.awsLogs isn't given a logGroup: ILogGroup prop, the CDK helpfully creates a LogGroup. This CDK-created LogGroup has the default Removal Policy, which is RemovalPolicy.RETAIN. And default RetentionDays is set to RetentionDays.TWO_YEARS. The RETAIN behaviour will "orphan" the resource:

> This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained in the account, but orphaned from the stack.

If you want to have CloudFormation tidy up, pass your own LogGroup to awsLogs with RemovalPolicy.DESTROY.

huangapple
  • 本文由 发表于 2023年5月13日 20:26:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76242717.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定