在aws cloudformation期间找不到资源publicip for resource

时间:2018-06-01 09:54:32

标签: amazon-web-services amazon-cloudformation

我是非常新的数据,我尝试在私有VPC中使用Neo4j安装启动EC2,我发现有人已经使用Neo4j创建了一个云形态模板,但该实例适用于公共VPC,所以我修改了模板以适应我的目的,但是当我启动它时我遇到了这个问题:'找不到属性的公共资源'

以下是脚本的一部分(没有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地址的情况下使用“启动实例向导”中的“配置实例详细信息”吗?

谢谢

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:1)

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

答案 2 :(得分:1)

也许您想对实例逻辑ID进行Fn :: GetAtt以在代码中的某个位置获取PublicIp,并且实例未为其分配PublicIp。