我想让多个帐户中的CodeDeploy CloudWatch事件由另一个帐户中的Lambda处理。
这是在堆栈中定义的资源,它将在帐户222222222222和333333333333中运行:
Rule codedeployEventRule = Rule.Builder.create(this, "codedeploy-event-rule")
.description("CloudWatch event rule covering all CodeDeploy events.")
.ruleName("codedeploy-event-rule-".concat(props.getEnv().getAccount()))
.enabled(true)
.targets(List.of(LambdaFunction.Builder.create(codedeployLambdaTarget)
.build()))
.eventPattern(EventPattern.builder()
.source(List.of("aws.codedeploy"))
.build())
.build();
我正在尝试找出如何从在帐户111111111111(目标帐户)中创建的堆栈中获取IFunction并在上面的事件Rule
中对其进行引用。我可以成功部署第一个堆栈:
cdk deploy --app cdk-system/build/cdk.out MyFirstStackThatDefinesTheLambda
我尝试通过参数将其传递到第二个堆栈的构造函数中,从而从第二个堆栈(IFunction
)引用MyFirstStackThatDefinesTheLambda
(即尝试遵循建议here) ),但是当我尝试使用第二个堆栈的凭据部署第二个堆栈(222222222222)时,出现一个错误,提示如何没有查询第一个堆栈的凭据(111111111111没有凭据)。
cdk deploy --app cdk-system/build/cdk.out My2ndStackProducingCodeDeployEvents
我收到如下错误:
Error: Need to perform AWS calls for account 111111111111, but no credentials found. Tried: default credentials.