2016-10-26 11 views
2

これは関係なく、私は、スタックを作成するとき、私は常に次のエラーを取得しようとするもの、私は怒って駆動され、「パラメータグループ名は、パラメータのサブネットで使用することはできません」セキュリティグループ、サブネットは同じVPCにあります。どんな助言もすばらしいでしょう、ありがとうAWS CFN

{ 
    "AWSTemplateFormatVersion" : "2010-09-09", 

    "Description" : "Microsoft SQL 2012 R2 Test Application Stack", 

    "Parameters" : { 
    "pInstanceName" : { 
     "Description" : "Instance name (up to 15 characters)", 
     "Type" : "String", 
     "MinLength" : "1", 
     "MaxLength" : "15", 
     "AllowedPattern" : "[a-zA-Z0-9]+", 
     "Default" : "aws2xxxxxxxxxxx" 
    }, 
    "pInstanceType" : { 
     "Description" : "EC2 instance type", 
     "Type" : "String", 
     "AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"], 
     "ConstraintDescription" : "must be a valid EC2 instance type", 
     "Default" : "t2.small" 
    }, 
    "pAmi" : { 
     "Description" : "AMI required to provision instance", 
     "Type" : "String", 
     "Default" : "ami-55084526" 
    }, 
    "pVolumeSize" : { 
     "Description" : "Root volume size", 
     "Type" : "String", 
     "Default" : "60" 
    }, 
    "pKeyPairName" : { 
     "Description" : "Name of key pair to use", 
     "Type" : "String", 
     "Default" : "win_keys" 
    }, 
    "pAz" : { 
     "Description" : "Availability Zone of instance", 
     "Type" : "String", 
     "AllowedValues" : [ 
      "eu-west-1b", 
      "eu-west-1c" 
     ], 
     "Default" : "eu-west-1b" 
    }, 
    "pVpcId" : { 
     "Description" : "VPC-ID", 
     "Type" : "AWS::EC2::VPC::Id", 
     "Default" : "vpc-7xxxx513" 
    }, 
    "pVpcName" : { 
     "Description" : "VPC of instance", 
     "Type" : "String", 
     "MinLength" : "3", 
     "MaxLength" : "4", 
     "AllowedPattern" : "^(aws)\\d", 
     "Default" : "aws" 
    }, 
    "pEnvironment" : { 
     "Description" : "Environment", 
     "Type" : "String", 
     "Default" : "preProduction", 
     "AllowedValues" : [ 
      "development", 
      "test", 
      "preProduction", 
      "production" 
     ], 
     "ConstraintDescription" : "specify environment stack" 
    }, 
    "pSystem" : { 
     "Description" : "Application or System instance is part of", 
     "Type" : "String", 
     "Default" : "n/a" 
    }, 
    "pDefaultSg" : { 
     "Description" : "Default VPC Security Groups", 
     "Type" : "List<AWS::EC2::SecurityGroup::Id>", 
     "Default" : "sg-24xxxx41,sg-2xxxx342,sg-235bxxxx" 
    }, 
    "pServerRole" : { 
     "Description" : "Role of the instance", 
     "Type" : "String", 
     "Default" : "n/a" 
    }, 
    "pOwnerContact" : { 
     "Description" : "Owner email address responsible for instance", 
     "Type" : "String", 
     "AllowedPattern" : "([a-zA-Z0-9]|-|\\.)[email protected]([a-zA-Z0-9]|-|\\.)+", 
     "ConstraintDescription" : "Owner email address: [email protected]", 
     "Default" : "[email protected]" 
    }, 
    "pDepartment" : { 
     "Description" : "Department responsible for instance ", 
     "Type" : "String", 
     "Default" : "n/a" 
    }, 
    "pProjectCode" : { 
     "Description" : "Project or Cost Centre code", 
     "Type" : "String", 
     "MinLength" : "1", 
     "MaxLength" : "30", 
     "Default" : "n/a" 
    }, 
    "pVersion" : { 
     "Description" : "Version of resource", 
     "Type" : "String", 
     "Default" : "n/a" 
    }, 
    "pCreationDate" : { 
     "Description" : "Creation date of instance", 
     "Type" : "String", 
     "AllowedPattern" : "^\\d{4}(-\\d{2}){2}", 
     "Default" : "2016-10-25" 
    } 
    },  
    "Resources" : { 
    "sgTestPre" : { 
     "Type" : "AWS::EC2::SecurityGroup", 
      "Properties" : { 
       "GroupDescription" : "Security Group for Test environments", 
       "VpcId" : { "Ref" : "pVpcId" }, 
       "SecurityGroupIngress" : [ { 
        "IpProtocol" : "tcp", 
        "FromPort" : "3389", 
        "ToPort" : "3389", 
        "CidrIp" : "192.168.0.0/16" 
       } ] 
      } 
    }, 
    "ec2Instance" : { 
     "Type" : "AWS::EC2::Instance", 
     "Properties" : { 
      "ImageId" : { "Ref" : "pAmi" }, 
      "InstanceType" : { "Ref" : "pInstanceType" }, 
      "KeyName" : { "Ref" : "pKeyPairName" }, 
      "SecurityGroupIds" : [ 
       {"Fn::Join": 
        [",", 
         {"Ref": "pDefaultSg"} 
        ] 
       }, 
       { "Fn::GetAtt": ["sgTestPre", "GroupId"] } 
      ], 
      "SubnetId" : "subnet-3xxxx948", 
      "BlockDeviceMappings" : [ { 
       "DeviceName" : "/dev/sda1", 
       "Ebs" : { "VolumeSize" : {"Ref": "pVolumeSize"} } 
      } ], 
      "Tags" : [ 
       { 
        "Key" : "Name", 
        "Value" : { "Ref" : "pInstanceName" } 
       }, 
       { 
        "Key" : "Environment", 
        "Value" : { "Ref" : "pEnvironment" } 
       }, 
       { 
        "Key" : "System", 
        "Value" : { "Ref" : "pSystem" } 
       }, 
       { 
        "Key" : "ServerRole", 
        "Value" : { "Ref" : "pServerRole" } 
       }, 
       { 
        "Key" : "OwnerContact", 
        "Value" : { "Ref" : "pOwnerContact" } 
       }, 
       { 
        "Key" : "Department", 
        "Value" : { "Ref" : "pDepartment" } 
       }, 
       { 
        "Key" : "ProjectCode", 
        "Value" : { "Ref" : "pProjectCode" } 
       }, 
       { 
        "Key" : "VpcName", 
        "Value" : { "Ref" : "pVpcName" } 
       }, 
       { 
        "Key" : "Version", 
        "Value" : { "Ref" : "pVersion" } 
       }, 
       { 
        "Key" : "CreationDate", 
        "Value" : { "Ref" : "pCreationDate" } 
       } 
      ] 
     } 
    } 
    }, 
    "Outputs" : { 
    } 
} 
+0

スタックを実行するために使用するコマンド全体を表示します。 – Darek

+0

こんにちは、スタックはAWS Console内から実行され、デフォルトが受け入れられます。 –

答えて

0

以下は、動作させるためにcftで必要とされる変更です。

SGのリストを使用するのではなく、パラメータセクションでCommaDelimitedListを使用します。

"pDefaultSg" : { 
    "Description" : "Default VPC Security Groups", 
    "Type": "CommaDelimitedList", 
    "Default" : "sg-xxxxx,sg-xxxxx,sg-xxxx" 
}, 

Ec2インスタンス作成では、以下のセクションを使用してsgsを添付します。

"SecurityGroupIds" : [{ "Fn::Select" : [ "0", {"Ref" : "pDefaultSg"} ] },{ "Fn::Select" : [ "1", {"Ref" : "pDefaultSg"} ] },{ "Fn::Select" : [ "2", {"Ref" : "pDefaultSg"} ] },{ "Fn::GetAtt": ["sgTestPre", "GroupId"] }], 

希望すると助かります。

1

実際のSecurityGroup IDを参照していて、名前は参照していないことを確認してください。あなたが使用する場合:{[ "MySecurityGroupResourceName"、 "グループID"] "のFn :: GetAtt"}

はあなたが参考を行っているGetAttすべてあなたのID

を収集するために:のFn組み込み関数を使用IDではなく、デフォルトのVPCを使用する場合は名前を取得します。ドキュメント:

"... Ref関数の引数としてAWS :: EC2 :: SecurityGroupタイプを指定すると、AWS CloudFormation はセキュリティグループ名またはセキュリティグループID(EC2-デフォルトのVPCにないVPCセキュリティグループ).... "

関連する問題