【问题标题】:cfn-init will not work in VPC using Cloud Formationcfn-init 在使用 Cloud Formation 的 VPC 中不起作用
【发布时间】:2012-10-02 07:38:39
【问题描述】:

这是我第一次尝试使用 VPC。

我刚刚将模板更改为使用 VPC。当堆栈在 VPC 之外启动时一切都很好,但现在它们在 VPC 内部,我无法在使用 cfn-init (Ec2Config) 包启动实例期间从 S3 下载我的文件。它是一个 Windows 盒子。

我在 cfn-init 日志中看到以下日志:

2012-10-11 08:11:40,992 DEBUG Client initialized with endpoint https://cloudformation.us-east-1.amazonaws.com  
2012-10-11 08:11:41,523 DEBUG Describing resource LaunchConfigName in stack StackName  
2012-10-11 08:12:03,113 ERROR URLError: getaddrinfo returns an empty list  
2012-10-11 08:12:03,144 DEBUG Sleeping for 0.921699 seconds before retrying  
2012-10-11 08:12:25,109 ERROR URLError: getaddrinfo returns an empty list  
2012-10-11 08:12:25,109 DEBUG Sleeping for 1.240427 seconds before retrying  
2012-10-11 08:12:47,386 ERROR URLError: getaddrinfo returns an empty list  
2012-10-11 08:12:47,386 DEBUG Sleeping for 5.528233 seconds before retrying  
2012-10-11 08:13:13,968 ERROR URLError: getaddrinfo returns an empty list  
2012-10-11 08:13:13,968 DEBUG Sleeping for 4.688940 seconds before retrying  
2012-10-11 08:13:39,677 ERROR URLError: getaddrinfo returns an empty list  

我在 cfn-hup 日志中看到以下日志:

2012-10-11 08:23:06,550 ERROR Error: could not find main configuation at C:\cfn\cfn-hup.conf  
2012-10-11 08:23:06,893 ERROR Error: main section must contain stack option  
2012-10-11 08:33:06,089 ERROR Error: could not find main configuation at C:\cfn\cfn-hup.conf  
2012-10-11 08:33:06,370 ERROR Error: main section must contain stack option  
2012-10-11 08:43:06,533 ERROR Error: could not find main configuation at C:\cfn\cfn-hup.conf  
2012-10-11 08:43:06,876 ERROR Error: main section must contain stack option  
2012-10-11 08:53:06,119 ERROR Error: could not find main configuation at C:\cfn\cfn-hup.conf  
2012-10-11 08:53:06,416 ERROR Error: main section must contain stack option  

从实例中我可以通过网络浏览器访问互联网。

【问题讨论】:

    标签: bootstrapping amazon-cloudformation amazon-vpc


    【解决方案1】:

    您需要设置一个 NAT 服务器或为盒子分配一个弹性 IP 地址,否则它无法与互联网通信。

    【讨论】:

      【解决方案2】:

      这有点老了,但我最近在类似的问题上花了很多时间。 使用 cfn-init 时,仅添加 NAT 或网关是不够的。在运行 cfn-init 的实例和网关之间还需要添加一个依赖:

      "MyInstance1" : {
        "Type"  : "AWS::EC2::Instance",       
        "DependsOn" : "Gateway",
        ....
      }
      

      【讨论】:

        【解决方案3】:

        我在尝试运行 Active Directory CF 模板时遇到了类似的问题,尽管我得到的错误略有不同:

        gaierror(11001, 'getaddrinfo failed')
        

        这与 VPC 上设置的 DHCP 选项有关。

        我需要设置域控制器的域:

        Options:
            domain-name = example.com
            domain-name-servers = AmazonProvidedDNS
        

        显然,一旦我将 DC 设置为 DNS 服务器,我就可以将 Amazon Provided 语句更改为我自己的 IP。

        【讨论】:

          猜你喜欢
          • 2019-03-07
          • 1970-01-01
          • 1970-01-01
          • 2015-01-03
          • 2019-06-29
          • 2019-07-05
          • 2016-02-14
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多