2016-10-26 2 views
2

이 상관없이 내가 스택을 만들 때 항상 다음과 같은 오류가 무엇을하려고 나를 미친 운전이다 "매개 변수 groupName을이 매개 변수 서브넷와 함께 사용할 수 없습니다" 보안 그룹, 서브넷이 동일한 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에 list를 사용하는 대신 매개 변수 섹션에서 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

실제 보안 그룹 ID가이고 참조 이름이 아닌지 확인하십시오. 당신이 사용하는 경우 : {[ "MySecurityGroupResourceName", "그룹 ID"] "FN :: GetAtt"}

당신이 참조가는 GetAtt 모든 당신의 식별자

를 수집 : FN 내장 함수 를 사용 ID가 아닌 기본 VPC를 사용하는 경우 이름을 가져옵니다. 문서에서 :

"... Ref 함수의 인수로 AWS :: EC2 :: SecurityGroup 유형을 지정하면 AWS CloudFormation 은 보안 그룹 이름 또는 보안 그룹 ID (EC2- 기본 VPC에없는 VPC 보안 그룹) .... "

관련 문제