【问题标题】:Adding an option group using AWS CloudFormation使用 AWS CloudFormation 添加选项组
【发布时间】:2015-06-25 20:50:01
【问题描述】:

我正在构建一个 CloudFormation 模板,该模板将使用多可用区选项创建一个 SQL Server 数据库(使用 RDS)(因此它在不同的可用区维护一个同步备用副本)。

但是,为了完成这项工作,我需要将数据库实例与具有镜像选项的选项组相关联。无法在任何地方找到如何使用 CloudFormation 模板创建选项组。

如何在 CloudFormation 模板中创建选项组?

【问题讨论】:

    标签: amazon-web-services rds amazon-cloudformation


    【解决方案1】:

    到目前为止,CloudFormation 不支持选项组。如果需要在模板中创建数据库,您可以预先创建带有cli 的选项组并将其设置为参数。这样您就可以正确地为AWS::RDS::DBInstance 资源填充OptionGroupName 值。

    【讨论】:

      【解决方案2】:

      CloudFormation 模板尚不支持复制组功能。因此,唯一可能的方法是创建一个外部 python 脚本,该脚本将使用 Boto lib 创建复制组

      示例如何创建 Redis 复制组

      import boto.elasticache
      import time
      import sys
      
      connection = boto.elasticache.connect_to_region('ap-southeast-2')
      
      connection.create_cache_subnet_group(
          "Redis-Subnet-Group-Test", 
          "Redis cluster subnet", 
          ["subnet-72313306", "subnet-7a06e01f"]
      )
      
      connection.create_cache_cluster(
          "Redis-Master-Test", 
          num_cache_nodes = 1, 
          cache_node_type = "cache.t1.micro", 
          engine = "redis", 
          engine_version = "2.6.13", 
          cache_subnet_group_name = "Redis-Subnet-Group-Test", 
          security_group_ids = ["sg-07ff1962"],
          preferred_availability_zone = "ap-southeast-2a",
          preferred_maintenance_window = "tue:01:00-tue:02:00",
          auto_minor_version_upgrade = True
      )
      
      counter = 0
      while counter < 35: # Wait for the cache cluster (redis master) to become available before creating the replication group
          counter = counter + 1
          clusterDesc = connection.describe_cache_clusters(cache_cluster_id = "Redis-Master-Test")
          clusterStatus = clusterDesc["DescribeCacheClustersResponse"]["DescribeCacheClustersResult"]["CacheClusters"][0]["CacheClusterStatus"];
      
          if "available" not in clusterStatus:
              time.sleep(10)
      
          elif "available" in clusterStatus:
              break
      
          else: # Just roll back on timeout
              connection.delete_cache_cluster("Redis-Master-Test")
              connection.delete_cache_subnet_group("Redis-Subnet-Group-Test")
              sys.exit(1)
      
      connection.create_replication_group("Redis-Replicas-Test", "Redis-Master-Test", "Redis-Replication-Group")
      
      connection.create_cache_cluster(
          "Redis-Replica-Test",
          num_cache_nodes = 1, 
          replication_group_id = "Redis-Replicas-Test",
          cache_node_type = "cache.t1.micro", 
          engine = "redis", 
          engine_version = "2.6.13", 
          cache_subnet_group_name = "Redis-Subnet-Group-Test", 
          security_group_ids = ["sg-07ff1962"],
          preferred_availability_zone = "ap-southeast-2b",
          preferred_maintenance_window = "tue:01:00-tue:02:00",
          auto_minor_version_upgrade = True
      )
      

      【讨论】:

      • 感谢您的回答,但我认为您很困惑。我的问题是关于选项组而不是复制组,我使用的是 RDS 而不是 Redis。
      • 抱歉让您感到困惑...Redis 只是我在案例中遇到的一个类似示例,发现无法通过模板制作(信息已由亚马逊确认),我认为这种情况与 RDS 类似,尤其是在您找不到任何如何通过 CloudFormation 创建它的信息的情况下
      猜你喜欢
      • 1970-01-01
      • 2020-09-29
      • 2019-07-05
      • 2016-08-30
      • 1970-01-01
      • 2014-11-25
      • 2019-05-09
      • 2023-03-19
      • 1970-01-01
      相关资源
      最近更新 更多