Nim*_*ale 1 amazon-web-services aws-cloudformation
根据我的理解,如果更新了指定了 DependsOn 的资源,则应该更新它所依赖的资源。我在某些资源中看到了这一点,但它似乎不适用于自定义资源。
我正在使用 APIGateway 并尝试在与阶段相关的资源更新时使用自定义资源来部署阶段。这是因为当需要部署更新时,包含的AWS::ApiGateway::Stage&AWS::ApiGateway::Deployment似乎不能很好地工作。
我有以下模板(为了便于参考而进行了剪裁):
<snip>
pipelineMgrStateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
<snip>
webhookEndPointMethod:
Type: AWS::ApiGateway::Method
DependsOn: pipelineMgrStateMachine
Properties:
RestApiId: !Ref pipelineMgrGW
ResourceId: !Ref webhookEndPointResource
HttpMethod: POST
AuthorizationType: NONE
Integration:
Type: AWS
IntegrationHttpMethod: POST
Uri: !Sub arn:aws:apigateway:${AWS::Region}:states:action/StartExecution
Credentials: !GetAtt pipelineMgrGWRole.Arn
PassthroughBehavior: WHEN_NO_TEMPLATES
RequestTemplates:
application/json: !Sub |
{
"input": "$util.escapeJavaScript($input.json('$'))",
"name": "$context.requestId",
"stateMachineArn": "${pipelineMgrStateMachine}"
}
IntegrationResponses:
- StatusCode: 200
MethodResponses:
- StatusCode: 200
pipelineMgrStageDeployer:
Type: Custom::pipelineMgrStageDeployer
DependsOn: webhookEndPointMethod
Properties:
ServiceToken: !GetAtt apiGwStageDeployer.Arn
StageName: pipelinemgr
RestApiId: !Ref pipelineMgrGW
<snip>
Run Code Online (Sandbox Code Playgroud)
当我更新pipelineMgrStateMachine资源时,我看到webhookEndPointMethod即使webhookEndPointMethod. 正如预期的那样。
但是,pipelineMgrStageDeployer没有更新。即使我pipelineMgrStageDeployer直接依赖pipelineMgrStateMachine.
关于为什么自定义资源在其依赖的资源更新时不更新的任何想法?还有其他可能有用的想法或见解吗?
谢谢,乔
对于其用途似乎存在误解DependsOn。
这是怎么回事
来自 CloudFormation DependsOn 文档
使用 DependsOn 属性,您可以指定特定资源的创建遵循另一个资源的创建。将 DependsOn 属性添加到资源时,仅在创建 DependsOn 属性中指定的资源后才会创建该资源。
webhookEndPointMethod当您更新时,您可能会更新的原因pipelineMgrStateMachine是因为它对您有隐式依赖RequestTemplates
"stateMachineArn": "${pipelineMgrStateMachine}"
如何使您的自定义资源得到更新
至于如何在状态管理器更新时更新部署程序自定义资源,您可以将一个属性添加到您实际上并未在其中使用的自定义资源中,例如PipelineMgStateMachine: !Ref pipelineMgrStateMachine:
pipelineMgrStageDeployer:
Type: Custom::pipelineMgrStageDeployer
DependsOn: webhookEndPointMethod
Properties:
ServiceToken: !GetAtt apiGwStageDeployer.Arn
StageName: pipelinemgr
RestApiId: !Ref pipelineMgrGW
PipelineMgStateMachine: !Ref pipelineMgrStateMachine
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3032 次 |
| 最近记录: |