Exemple #1
0
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"),
		}
}
Exemple #2
0
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
}
Exemple #3
0
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
}
Exemple #4
0
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"),
		}
}
Exemple #5
0
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
}
Exemple #6
0
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
}
Exemple #7
0
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
}
Exemple #8
0
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,
	}
}
Exemple #9
0
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,
	}
}
Exemple #10
0
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,
	}
}
Exemple #11
0
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,
	}
}
Exemple #12
0
func (recordSet RecordSet) PointTo(elasticIP cloudformer.ElasticIP) {
	recordSet.model.RecordSetType = "A"
	recordSet.model.ResourceRecords = []models.Hash{models.Ref(elasticIP.(ElasticIP).name + "EIP")}
}
Exemple #13
0
func (elasticIP ElasticIP) AttachTo(instance cloudformer.Instance) {
	elasticIP.model.InstanceId =
		models.Ref(instance.(Instance).name + "Instance")
}