func (vpc VPC) AttachInternetGateway(gateway cloudformer.InternetGateway) { vpc.resources[vpc.name+"VPCGatewayAttachment"] = &models.VPCGatewayAttachment{ VpcId: models.Ref(vpc.name + "VPC"), InternetGatewayId: models.Ref(gateway.(InternetGateway).name + "InternetGateway"), } }
func (routeTable RouteTable) Instance(gateway cloudformer.Instance) { route := &models.Route{ DestinationCidrBlock: "0.0.0.0/0", RouteTableId: models.Ref(routeTable.name + "RouteTable"), InstanceId: models.Ref(gateway.(Instance).name + "Instance"), Depends: gateway.(Instance).name + "Instance", } routeTable.resources[routeTable.name+"Route"] = route }
func (routeTable RouteTable) InternetGateway(gateway cloudformer.InternetGateway) { route := &models.Route{ DestinationCidrBlock: "0.0.0.0/0", RouteTableId: models.Ref(routeTable.name + "RouteTable"), GatewayId: models.Ref(gateway.(InternetGateway).name + "InternetGateway"), Depends: gateway.(InternetGateway).name + "InternetGateway", } routeTable.resources[routeTable.name+"Route"] = route }
func (vpc VPC) AssociateDHCPOptions(options cloudformer.DHCPOptions) { vpc.resources[vpc.name+"DHCPOptions"] = &models.DHCPOptions{ DomainNameServers: options.DomainNameServers, } vpc.resources[vpc.name+"VPCDHCPOptionsAssociation"] = &models.VPCDHCPOptionsAssociation{ VpcId: models.Ref(vpc.name + "VPC"), DhcpOptionsId: models.Ref(vpc.name + "DHCPOptions"), } }
func (balancer LoadBalancer) SecurityGroup(group cloudformer.SecurityGroup) { securityGroups := balancer.model.SecurityGroups.([]interface{}) securityGroups = append( securityGroups, models.Ref(group.(SecurityGroup).name+"SecurityGroup"), ) balancer.model.SecurityGroups = securityGroups }
func (balancer LoadBalancer) Subnet(subnet cloudformer.Subnet) { subnets := balancer.model.Subnets.([]interface{}) subnets = append( subnets, models.Ref(subnet.(Subnet).name+"Subnet"), ) balancer.model.Subnets = subnets }
func (instance Instance) SecurityGroup(securityGroup cloudformer.SecurityGroup) { groups := instance.model.SecurityGroupIds.([]interface{}) groups = append( groups, models.Ref(securityGroup.(SecurityGroup).name+"SecurityGroup"), ) instance.model.SecurityGroupIds = groups }
func (subnet Subnet) RouteTable() cloudformer.RouteTable { model := &models.RouteTable{ VpcId: subnet.model.VpcId, } subnet.resources[subnet.name+"RouteTable"] = model subnet.resources[subnet.name+"SubnetRouteTableAssociation"] = &models.SubnetRouteTableAssociation{ SubnetId: models.Ref(subnet.name + "Subnet"), RouteTableId: models.Ref(subnet.name + "RouteTable"), } return RouteTable{ name: subnet.name, model: model, resources: subnet.resources, } }
func (vpc VPC) SecurityGroup(name string) cloudformer.SecurityGroup { model := &models.SecurityGroup{ GroupDescription: name, VpcId: models.Ref(vpc.name + "VPC"), SecurityGroupIngress: []interface{}{}, SecurityGroupEgress: []interface{}{}, } vpc.resources[name+"SecurityGroup"] = model return SecurityGroup{ name: name, model: model, } }
func (vpc VPC) Subnet(name string) cloudformer.Subnet { model := &models.Subnet{ VpcId: models.Ref(vpc.name + "VPC"), Tags: []models.Tag{ {Key: "Name", Value: name}, }, } vpc.resources[name+"Subnet"] = model return Subnet{ name: name, model: model, resources: vpc.resources, } }
func (subnet Subnet) Instance(name string) cloudformer.Instance { if subnet.model.AvailabilityZone == "" { panic("must set availability zone on subnet before creating an instance") } model := &models.Instance{ AvailabilityZone: subnet.model.AvailabilityZone, SubnetId: models.Ref(subnet.name + "Subnet"), SecurityGroupIds: []interface{}{}, Tags: []models.Tag{ {Key: "Name", Value: name}, }, } subnet.resources[name+"Instance"] = model return Instance{ name: name, model: model, } }
func (recordSet RecordSet) PointTo(elasticIP cloudformer.ElasticIP) { recordSet.model.RecordSetType = "A" recordSet.model.ResourceRecords = []models.Hash{models.Ref(elasticIP.(ElasticIP).name + "EIP")} }
func (elasticIP ElasticIP) AttachTo(instance cloudformer.Instance) { elasticIP.model.InstanceId = models.Ref(instance.(Instance).name + "Instance") }