Cloudformation 找不到区域性 Opsworks 堆栈
Posted
技术标签:
【中文标题】Cloudformation 找不到区域性 Opsworks 堆栈【英文标题】:Regional Opsworks stack can't be found by Cloudformation 【发布时间】:2017-11-05 22:14:13 【问题描述】:我有一个 Cloudformation
模板,它通过添加少量资源来修改 Opsworks
堆栈。
Opsworks stack
部署在区域eu-west-1
中,这也是API endpoint region
,它显示在堆栈名称的一侧:Regional
。
当我运行 Cloudformation template
(我将堆栈 ID 作为参数提供)时,我收到此错误:
Unable to find stack with ID xxxxxxx
我猜 Cloudformation 只能看到 us-east-1 区域的 opsworks 资源?
我尝试更改 Cloudformation 的区域并部署模板,但仍然找不到堆栈。
如何让Cloudformation
在所有区域搜索堆栈?
我应该克隆 opsworks 堆栈并将端点更改为 us-east-1 区域吗?
最好的解决方案是什么?
模板
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Add a layer to an existing stack",
"Mappings":
"Region2Principal":
"eu-west-1":
"EC2Principal": "ec2.amazonaws.com",
"OpsWorksPrincipal": "opsworks.amazonaws.com"
,
,
"Parameters":
"Environment" :
"Description": "The Environnement variable ",
"Type": "String",
"Default": "dev",
"AllowedValues" : ["test", "prod"]
,
"InstanceType":
"Type": "String",
"Default": "m4.large",
"AllowedValues" : ["t2.micro", "m1.small", "m1.large","m4.large","m4.xlarge","m4.2xlarge","m4.4xlarge","m4.10xlarge","m4.16xlarge","c4.large" , "c4.xlarge" ,"c4.2xlarge" , "c4.4xlarge","c4.8xlarge" , "c3.large" , "c3.xlarge", "c3.2xlarge", "c3.4xlarge" ,"c3.8xlarge"],
"ConstraintDescription": "must be a valid EC2 instance type"
,
"StackID":
"Type": "String",
"Description": "ID of the existing opsworks stack to edit"
,
"vpcId":
"Description": "VPC id of corresponding to the Environment",
"Type": "String"
,
"subnetIds" :
"Description": "list of sunbnets in the chosen VPC",
"Type": "List<AWS::EC2::Subnet::Id>"
,
"ScriptSG":
"Description": "script security group",
"Type" : "String"
,
"SG":
"Description": " layer security group",
"Type": "String"
,
"Resources":
"Layer":
"Type": "AWS::OpsWorks::Layer",
"Properties":
"AutoAssignElasticIps" : false,
"AutoAssignPublicIps" : true
,
"SInstance1":
"Type": "AWS::OpsWorks::Instance",
"Properties":
"Hostname": "S1",
"AutoScalingType": "timer",
"TimeBasedAutoScaling" :
"Friday" : "0" : "on", "6" : "on", "12" : "on", "18" : "on" ,
"Monday" : "0" : "on", "6" : "on", "12" : "on", "18" : "on"
,
"RootDeviceType": "ebs",
"StackId": "Ref": "StackID",
"LayerIds": ["Ref": "Layer"],
"InstanceType": "Ref" : "InstanceType"
,
"Instance2":
"Type": "AWS::OpsWorks::Instance",
"Properties":
"Hostname": "S2",
"AutoScalingType": "timer",
"TimeBasedAutoScaling" :
"Saturday": "0" : "on", "6" : "on", "12" : "on", "18" : "on" ,
"Sunday" : "0" : "on", "6" : "on", "12" : "on", "18" : "on" ,
"Thursday": "0" : "on", "6" : "on", "12" : "on", "18" : "on" ,
"Tuesday" : "0" : "on", "6" : "on", "12" : "on", "18" : "on" ,
"Wednesday": "0" : "on", "6" : "on", "12" : "on", "18" : "on"
,
"RootDeviceType": "ebs",
"StackId": "Ref": "StackID",
"LayerIds": ["Ref": "Layer"],
"InstanceType": "Ref" : "InstanceType"
,
"ELB":
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties":
"ConnectionDrainingPolicy" :
"Enabled" : true,
"Timeout" : 300
,
"ConnectionSettings" :
"IdleTimeout" : 60
,
"CrossZone" : true,
"HealthCheck" :
"HealthyThreshold" : "3",
"Interval" : "30",
"Target" : "HTTP:80/ping",
"Timeout" : "5",
"UnhealthyThreshold" : "2"
,
"LoadBalancerName": "loadBalancer",
"Listeners" : [
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "80",
"Protocol" : "HTTP"
],
"Scheme" : "internal",
"SecurityGroups" : [ "Ref" : "ELBSecurityGroup" ],
"Subnets" : "Ref" : "subnetIds"
,
"ELBAttach":
"Type": "AWS::OpsWorks::ElasticLoadBalancerAttachment",
"Properties":
"ElasticLoadBalancerName" : "Ref" : "ELB",
"LayerId" : "Ref" : "Layer"
,
【问题讨论】:
【参考方案1】:您似乎需要将它们移动到同一区域。
只能在创建资源的区域内管理资源。在一个区域端点中创建的资源不可用,也不能克隆到另一个区域端点。
http://docs.aws.amazon.com/general/latest/gr/rande.html#opsworks_region
https://aws.amazon.com/about-aws/whats-new/2016/08/aws-opsworks-adds-nine-regional-endpoints-and-asia-pacific-seoul-region-support/
图层缺少 stackID 参数。
"Type": "AWS::OpsWorks::Layer",
"Properties":
"Attributes" : String:String ,
"AutoAssignElasticIps" : Boolean,
"AutoAssignPublicIps" : Boolean,
"CustomInstanceProfileArn" : String,
"CustomJson" : JSON object,
"CustomRecipes" : Recipes,
"CustomSecurityGroupIds" : [ String, ... ],
"EnableAutoHealing" : Boolean,
"InstallUpdatesOnBoot" : Boolean,
"LifecycleEventConfiguration" : LifeCycleEventConfiguration,
"LoadBasedAutoScaling" : LoadBasedAutoScaling,
"Name" : String,
"Packages" : [ String, ... ],
"Shortname" : String,
"StackId" : String,
"Type" : String,
"VolumeConfigurations" : [ VolumeConfiguration, ... ]
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-opsworks-layer.html
【讨论】:
我的默认区域是eu-west-1
,cloudformation 堆栈位于 eu-west-1
中,与 opsworks 端点相同的是 eu-west-1
。他们都在同一个区域,但是cloudformation找不到opsworks资源。
抱歉,将模板复制到此处时出错。该层确实有 stackID 作为参数。
并且stackID的形式是“StackId”:“aeb7523e-7c8b-49d4-b866-03aae9d4fbcb”
是的。我提供了我们在页面堆栈设置中找到的正确 ID。
您是否也尝试过堆栈的 ARN?以上是关于Cloudformation 找不到区域性 Opsworks 堆栈的主要内容,如果未能解决你的问题,请参考以下文章
AWS Cloudformation 输出 ElastiCacheCluster
AWS Cloudformation 启用 Performance Insights