amazon-web-services - cloudformation 延迟同一堆栈内的资源创建

标签 amazon-web-services aws-cloudformation

是否可以延迟同一堆栈中的资源创建?我有一个 DC 和另一台服务器,一旦 DC 设置完毕,需要加入域。两台服务器都是在同一堆栈中创建的。我尝试使用等待句柄,但它仍然同时创建这两个资源,然后在等待句柄的持续时间内表示正在创建。

编辑:按要求编写代码: 1.DC服务器的用户数据

        # "Fn::Base64":
    #   Fn::Join ["", [
    #   "<script>cfn-init -v --stack ", !Ref "AWS::StackName", " --resource DC --configsets ascending --region", !Ref "AWS::Region", "\n",
    #   "cfn-signal.exe -e 0 ", Fn::Base64 !Ref DCServerWaitHandle, "</script>"]]

等待句柄

DCServerWaitHandle:
  Type: AWS::CloudFormation::WaitConditionHandle
DCServerWaitCondition:
  Type: AWS::CloudFormation::WaitCondition
  DependsOn: DC
  Properties:
    Handle: !Ref DCServerWaitHandle
    Timeout: 600

那么应该等待 600 秒以构建 DC 的另一台服务器具有依赖项:DC 属性

最佳答案

通常您可以使用DependsOn功能按顺序创建资源。 特别是对于 EC2 实例,您可以使用 CreationPolicy Attribute防止资源达到完成状态。

来自docs :

For Amazon EC2 and Auto Scaling resources, we recommend that you use a CreationPolicy attribute instead of wait conditions. Add a CreationPolicy attribute to those resources, and use the cfn-signal helper script to signal when an instance creation process has completed successfully.

关于amazon-web-services - cloudformation 延迟同一堆栈内的资源创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44843048/

相关文章:

amazon-web-services - Azure 回复 url 在 AWS 负载均衡器后面始终不安全

amazon-web-services - AWS 云形成 : How to specify a bucket from another AWS account for Lambda code?

python - 如何在Python中导入S3cmd

amazon-web-services - 将 Cloudformation 与 Chef 服务器结合使用

amazon-web-services - 为什么我的子网和 VPC 在 CloudFormation 上并排显示

amazon-web-services - 如果所需的容器数量大于 1,则 ECS 服务处于挂起状态

aws-cloudformation - 避免用 CloudFormation 替换 TaskDefinition

amazon-web-services - AWS Elastic Beanstalk、Dockerrun.aws.json 和 docker run 上的多个端口

node.js - 使用 SES node.js 发送电子邮件

amazon-web-services - 无法识别AWS Cloudwatch日志流名称