2017-04-12 8 views
2

Ich bin für meine Datenbank mein Setup Cloudformation versuchen:Cloudformation mit Sicherheitsgruppe Mismatch Fehler

"VPC" : { 
    "Type" : "AWS::EC2::VPC", 
    "Properties" : { 
    "CidrBlock" : "10.0.0.0/16", 
    "EnableDnsSupport" : "false", 
    "EnableDnsHostnames" : "false", 
    "InstanceTenancy" : "default", 
    "Tags" : [ { "Key" : "Name", "Value" : "DomainName" } ] 
    } 
}, 

"Subnet" : { 
    "Type" : "AWS::EC2::Subnet", 
    "Properties" : { 
    "VpcId" : { "Ref" : "VPC" }, 
    "CidrBlock" : "10.0.0.0/16", 
    "AvailabilityZone" : { "Fn::Select": [ "0", { "Fn::GetAZs" : { "Ref" : "AWS::Region" } }]}, 
    "Tags" : [ { "Key" : "Name", "Value" : "DomainName" } ] 
    } 
}, 

"SecurityGroup" : { 
    "Type" : "AWS::EC2::SecurityGroup", 
    "Properties" : { 
    "GroupDescription" : "Allow http to client host", 
    "VpcId" : {"Ref" : "VPC"}, 
    "SecurityGroupIngress" : [{ 
     "IpProtocol" : "tcp", 
     "FromPort" : "3306", 
     "ToPort" : "3306", 
     "CidrIp" : "10.0.0.0/16" 
    }], 
    "Tags" : [ { "Key" : "Name", "Value" : "DomainName" } ] 
    } 
}, 

"Database" : { 
    "Type" : "AWS::RDS::DBInstance", 
    "Properties" : { 
    "DBName" : { "Fn::Join": ["", { "Fn::Split": [".", { "Ref" : "DomainName" }]}]}, 
    "AllocatedStorage" : "5", 
    "DBInstanceClass" : "db.t2.micro", 
    "Engine" : "MySQL", 
    "EngineVersion" : "5.5", 
    "MasterUsername" : { "Ref": "DBUsername" }, 
    "MasterUserPassword" : { "Ref": "DBPassword" }, 
    "VPCSecurityGroups" : [ { "Fn::GetAtt": [ "SecurityGroup", "GroupId" ] } ], 
    "Tags" : [ { "Key" : "Name", "Value" : "DomainName" } ] 
    }, 
    "DeletionPolicy" : "Snapshot" 
}, 

Sollte eine VPC bis zur Datenbank werden Einstellung. Aber wenn ich die Cloudformation-Vorlage betreibe ich die folgende Fehlermeldung erhalten:

UPDATE_FAILED AWS::RDS::DBInstance Database Database is in vpc-3081245b, but Ec2 Security Group sg-b122ffca is in vpc-f7173290

Wie erhalte ich meine Datenbank richtig in der VPC?

Antwort

2

Im Rahmen Ihrer Datenbankdefinition können Sie eine DBSubnetGroupName angeben.

A DB Subnet Group stellt eine Liste von Subnetzen, in dem die Datenbank ausgeführt werden darf. Jedes Subnetz in einer DB-Subnetzgruppe gehört zu einer VPC.

Daher müssen Sie das folgende in der Amazon Cloudformation-Vorlage tun:

  • ein AWS::RDS::DBSubnetGroup hinzufügen, die Subnet bereits definiert in Ihrer Vorlage
  • hinzufügen DBSubnetGroupName Parameter auf Ihre AWS::RDS::DBInstance Definition Angabe