簡體   English   中英

Cloudformation找不到區域Opsworks堆棧

[英]Regional Opsworks stack can't be found by Cloudformation

我有一個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" }
      }
    }
  },
}

看來您需要將它們移到相同的區域。

只能在創建資源的區域中管理資源。 在一個區域端點中創建的資源不可用,也無法將其克隆到另一個區域端點。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM