mirror of
https://github.com/docker/compose.git
synced 2025-07-17 10:44:26 +02:00
Fix resource naming
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
37177e6d7a
commit
fbb5bdac6e
@ -172,15 +172,10 @@ func (c client) Convert(project *compose.Project) (*cloudformation.Template, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c client) createLoadBalancer(project *compose.Project, template *cloudformation.Template) string {
|
func (c client) createLoadBalancer(project *compose.Project, template *cloudformation.Template) string {
|
||||||
loadBalancerType := "network"
|
loadBalancerName := fmt.Sprintf("%sLoadBalancer", strings.Title(project.Name))
|
||||||
loadBalancerName := fmt.Sprintf(
|
template.Resources[loadBalancerName] = &elasticloadbalancingv2.LoadBalancer{
|
||||||
"%s%sLB",
|
|
||||||
strings.Title(project.Name),
|
|
||||||
strings.ToUpper(loadBalancerType[0:1]),
|
|
||||||
)
|
|
||||||
loadBalancer := &elasticloadbalancingv2.LoadBalancer{
|
|
||||||
Name: loadBalancerName,
|
Name: loadBalancerName,
|
||||||
Scheme: "internet-facing",
|
Scheme: elbv2.LoadBalancerSchemeEnumInternetFacing,
|
||||||
Subnets: []string{
|
Subnets: []string{
|
||||||
cloudformation.Ref(ParameterSubnet1Id),
|
cloudformation.Ref(ParameterSubnet1Id),
|
||||||
cloudformation.Ref(ParameterSubnet2Id),
|
cloudformation.Ref(ParameterSubnet2Id),
|
||||||
@ -191,18 +186,17 @@ func (c client) createLoadBalancer(project *compose.Project, template *cloudform
|
|||||||
Value: project.Name,
|
Value: project.Name,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Type: loadBalancerType,
|
Type: elbv2.LoadBalancerTypeEnumNetwork,
|
||||||
}
|
}
|
||||||
template.Resources[loadBalancerName] = loadBalancer
|
|
||||||
return loadBalancerName
|
return loadBalancerName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c client) createListener(service types.ServiceConfig, port types.ServicePortConfig, template *cloudformation.Template, targetGroupName string, loadBalancerName string, protocol string) string {
|
func (c client) createListener(service types.ServiceConfig, port types.ServicePortConfig, template *cloudformation.Template, targetGroupName string, loadBalancerName string, protocol string) string {
|
||||||
listenerName := fmt.Sprintf(
|
listenerName := fmt.Sprintf(
|
||||||
"%s%s%sListener",
|
"%s%s%dListener",
|
||||||
normalizeResourceName(service.Name),
|
normalizeResourceName(service.Name),
|
||||||
strings.ToUpper(port.Protocol),
|
strings.ToUpper(port.Protocol),
|
||||||
string(port.Published),
|
port.Published,
|
||||||
)
|
)
|
||||||
//add listener to dependsOn
|
//add listener to dependsOn
|
||||||
//https://stackoverflow.com/questions/53971873/the-target-group-does-not-have-an-associated-load-balancer
|
//https://stackoverflow.com/questions/53971873/the-target-group-does-not-have-an-associated-load-balancer
|
||||||
@ -228,10 +222,10 @@ func (c client) createListener(service types.ServiceConfig, port types.ServicePo
|
|||||||
|
|
||||||
func (c client) createTargetGroup(project *compose.Project, service types.ServiceConfig, port types.ServicePortConfig, template *cloudformation.Template, protocol string) string {
|
func (c client) createTargetGroup(project *compose.Project, service types.ServiceConfig, port types.ServicePortConfig, template *cloudformation.Template, protocol string) string {
|
||||||
targetGroupName := fmt.Sprintf(
|
targetGroupName := fmt.Sprintf(
|
||||||
"%s%s%sTargetGroup",
|
"%s%s%dTargetGroup",
|
||||||
normalizeResourceName(service.Name),
|
normalizeResourceName(service.Name),
|
||||||
strings.ToUpper(port.Protocol),
|
strings.ToUpper(port.Protocol),
|
||||||
string(port.Published),
|
port.Published,
|
||||||
)
|
)
|
||||||
template.Resources[targetGroupName] = &elasticloadbalancingv2.TargetGroup{
|
template.Resources[targetGroupName] = &elasticloadbalancingv2.TargetGroup{
|
||||||
Name: targetGroupName,
|
Name: targetGroupName,
|
||||||
|
@ -23,6 +23,13 @@ func Normalize(model *types.Config) error {
|
|||||||
s.Networks = map[string]*types.ServiceNetworkConfig{"default": nil}
|
s.Networks = map[string]*types.ServiceNetworkConfig{"default": nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, p := range s.Ports {
|
||||||
|
if p.Published == 0 {
|
||||||
|
p.Published = p.Target
|
||||||
|
s.Ports[i] = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if s.LogDriver != "" {
|
if s.LogDriver != "" {
|
||||||
logrus.Warn("`log_driver` is deprecated. Use the `logging` attribute")
|
logrus.Warn("`log_driver` is deprecated. Use the `logging` attribute")
|
||||||
if s.Logging == nil {
|
if s.Logging == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user