【问题标题】:attribute publicip was not found for resource during aws cloudformation在 aws cloudformation 期间找不到资源的属性 publicip
【发布时间】:2018-11-11 10:33:47
【问题描述】:

我对 aws cloudformation 很陌生,我尝试在私有 VPC 中安装 Neo4j 启动 EC2,我发现有人已经使用 Neo4j 创建了 cloudformation 模板,但该实例是用于公共 VPC,所以我修改了模板以适应我的目的,但是当我启动它时遇到了这个问题:'attribute publicip was not found for resource'

这是脚本的一部分(没有 neo4j bash 脚本和 EBS 卷设置):

"Mappings" : {

"AWSRegionArch2AMI" : {
  "eu-west-1"      : { "64" : "ami-58d7e821" }
}

},

"Parameters": {
    "InstanceType" : {
    "Description" : "EC2 instance type",
    "Type" : "String",
    "Default" : "m5.large",
    "ConstraintDescription" : "Must be a valid EC2 instance type."
    },

    "SSHKeyName": {
      "Description": "Name of the SSH key that you will use to access the server (must be on AWS Availability Zone already)",
      "Type": "String"
    },

    "NetworkWhitelist": {
        "Description": " The IP address range that can be used to connect to the Neo4j server (by REST or SSH)",
        "Type": "String",
        "MinLength": "9",
        "MaxLength": "18",
        "Default": "",
        "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
        "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
    },

    "SubnetId" : {
        "Type" : "AWS::EC2::Subnet::Id",
        "Description" : "SubnetId of an existing subnet (for the primary network) in your Virtual Private Cloud (VPC)"
    },

    "SecurityGroupIds": {
        "Type": "AWS::EC2::SecurityGroup::Id",
        "Description" : "Existing SecurityGroups ID"
    },

    "AvailabilityZone": {
        "Type" : "AWS::EC2::AvailabilityZone::Name",
        "Description" : "Select the Availability Zone"
    }

},
"Resources": {
    "Server": {
        "Type": "AWS::EC2::Instance",
        "Properties": {
            "AvailabilityZone": {
                "Ref": "AvailabilityZone"
            },


            "DisableApiTermination": "FALSE",
            "ImageId": {
                "Fn::FindInMap": [ "AWSRegionArch2AMI", {
                    "Ref": "AWS::Region"
                }, "64"]
            },
            "InstanceType": {
                "Ref": "InstanceType"
            },
            "KeyName": {"Ref": "SSHKeyName"},
            "Monitoring": "false",
            "NetworkInterfaces" : [
                {
                    "AssociatePublicIpAddress": false,
                    "DeleteOnTermination": true,
                    "DeviceIndex": "0",
                    "SubnetId": {"Ref": "SubnetId"},
                    "GroupSet": [ {"Ref": "SecurityGroupIds"} ]
                }
            ],

我不能像在“启动实例向导”中的“配置实例详细信息”中那样启动没有公共 IP 地址的实例吗?

谢谢

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    您是否为尝试在其中创建实例的子网启用了“自动分配公共 IP”选项?因为您没有明确关联公共 IP 地址,所以它可能会失败,因为资源需要分配一个公共 IP 地址。测试这一点的可靠方法是将SubnetId 参数设置为在部署堆栈时不会自动分配公共 IP 地址的子网 ID。

    【讨论】:

      【解决方案2】:

      也许您要对 Instance 逻辑 Id 执行 Fn::GetAtt 以在代码中的某处获取 PublicIp,而 Instance 没有分配 PublicIp。

      【讨论】:

        【解决方案3】:

        就在几周前,我在使用 CloudFormation 时遇到了这个错误。在我的例子中,我放弃了接口的公共 IP,只支持私有 IP,但我仍然在 CloudFormation 模板中配置了一个输出,该输出引用了现在不存在的 publicid 属性。从模板中删除该输出解决了我的问题。

        【讨论】:

          猜你喜欢
          • 2018-01-12
          • 2021-05-01
          • 2019-05-07
          • 1970-01-01
          • 2017-07-01
          • 1970-01-01
          • 2018-10-25
          • 2021-04-16
          • 2020-01-09
          相关资源
          最近更新 更多