我有一個 cdk 堆疊,包括一個秘密堆疊,我目前正在嘗試部署我的應用程式,并且我最近從 ecr 中洗掉了一個秘密堆疊和容器。但是,由于當前部署的應用程式依賴于此,我在部署時得到以下資訊
Export <redacted>-*******-secrets-stack:ExportsOutputRefoauth2proxysecret66696FAADBFA07E9 cannot be deleted as it is in use by <redacted>-*******-ecs-stack
所以我加回了秘密堆疊
import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
interface SecretsStackProps extends StackProps {
namespace: string;
}
export class SecretsStack extends Stack {
public oauth2ProxySecrets: secretsmanager.Secret;
public appSecrets: secretsmanager.Secret;
constructor(scope: Construct, id: string, props: SecretsStackProps) {
super(scope, id, props);
// added this back
this.oauth2ProxySecrets = new secretsmanager.Secret(this, `oauth2-proxy-secret`, {
secretName: `${props.namespace}/<redacted>/oauth2-proxy`
}
);
//
this.appSecrets = new secretsmanager.Secret(this, `app-secret`, {
secretName: `${props.namespace}/<redacted>/app`
});
}
}
據我所知,我將如何保留這個堆疊,因為這個容器/堆疊沒有被使用,它試圖洗掉堆疊,但由于當前的部署而不能。
這里的任何幫助都會很棒。
uj5u.com熱心網友回復:
發生這種情況是因為它首先嘗試使用機密更新堆疊,然后是用于匯入它們的堆疊。
這會失敗,因為無法在匯入之前洗掉匯出。
移除堆疊的解決方案是使其成為一個兩步程序。首先,這是確保即使出口沒有在任何地方進口也能保留的主要保證。為此,存在一個輔助方法:Stack.exportValue.
因此,您需要將以下內容添加到匯出堆疊中:
this.exportValue(oauth2ProxySecrets.secretArn);
this.exportValue(appSecrets.secretArn);
完成此操作后,部署將通過。部署后,您可以完全洗掉堆疊代碼,因為它不會與其他堆疊解耦。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/466484.html
