Qin*_*jie 5 amazon-web-services aws-cdk
我使用 CDK 部署代码管道。它工作正常,直到我尝试添加代码管道成功/失败事件的通知。它给出了CREATE_FAILED错误消息Resource handler returned message: "Invalid request provided: AWS::CodeStarNotifications::NotificationRule" (RequestToken: bb566fd0-1ac9-5d61-03fe-f9c27b4196fa, HandlerErrorCode: InvalidRequest)。可能是什么原因?谢谢。
import * as codepipeline from "@aws-cdk/aws-codepipeline";
import * as codepipeline_actions from "@aws-cdk/aws-codepipeline-actions";
import * as codestar_noti from "@aws-cdk/aws-codestarnotifications";
import * as sns from "@aws-cdk/aws-sns";
const pipeline = new codepipeline.Pipeline(...);
const topicArn = props.sns_arn_for_developer;
const targetTopic = sns.Topic.fromTopicArn(
this,
"sns-notification-topic",
topicArn
);
new codestar_noti.NotificationRule(this, "Notification", {
detailType: codestar_noti.DetailType.BASIC,
events: [
"codepipeline-pipeline-pipeline-execution-started",
"codepipeline-pipeline-pipeline-execution-failed",
"codepipeline-pipeline-pipeline-execution-succeeded",
"codepipeline-pipeline-pipeline-execution-canceled",
],
source: pipeline,
targets: [targetTopic],
});
Run Code Online (Sandbox Code Playgroud)
这是生成的 cloudformation 模板的片段。
"Notification2267453E": {
"Type": "AWS::CodeStarNotifications::NotificationRule",
"Properties": {
"DetailType": "BASIC",
"EventTypeIds": [
"codepipeline-pipeline-pipeline-execution-started",
"codepipeline-pipeline-pipeline-execution-failed",
"codepipeline-pipeline-pipeline-execution-succeeded",
"codepipeline-pipeline-pipeline-execution-canceled"
],
"Name": "sagemakerbringyourownNotification36194CEC",
"Resource": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":codepipeline:ap-southeast-1:305326993135:",
{
"Ref": "sagemakerbringyourownpipeline0A8C43B1"
}
]
]
},
"Targets": [
{
"TargetAddress": "arn:aws:sns:ap-southeast-1:305326993135:whitespace_alerts",
"TargetType": "SNS"
}
]
},
"Metadata": {
"aws:cdk:path": "sagemaker-bring-your-own/Notification/Resource"
}
},
Run Code Online (Sandbox Code Playgroud)
"Invalid request provided: AWS::CodeStarNotifications::NotificationRule"FWIW,我从创建(未导入)的 CDK 应用程序中得到了完全相同的错误Topic。事实证明这是一个暂时的问题,因为第二次成功了,没有任何改变。我怀疑这是由于非常大的 ECR 映像所致,该映像是作为部署的一部分首次构建的,并且花费了相当长的时间。我的猜测是主题超时并进入某种奇怪的状态等待NotificationRule创建。
这是因为导入的资源无法修改。正如您在评论中指出的,设置通知涉及修改主题资源,特别是其访问策略。
参考:https ://docs.aws.amazon.com/cdk/v2/guide/resources.html#resources_importing
| 归档时间: |
|
| 查看次数: |
2893 次 |
| 最近记录: |