mirror of
https://github.com/docker/compose.git
synced 2025-07-08 22:34:26 +02:00
Check VPC has DNS resolution enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
f80e90caca
commit
cd27fcb9c8
17
ecs/sdk.go
17
ecs/sdk.go
@ -105,10 +105,19 @@ func (s sdk) CreateCluster(ctx context.Context, name string) (string, error) {
|
|||||||
return *response.Cluster.Status, nil
|
return *response.Cluster.Status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s sdk) VpcExists(ctx context.Context, vpcID string) (bool, error) {
|
func (s sdk) CheckVPC(ctx context.Context, vpcID string) error {
|
||||||
logrus.Debug("CheckRequirements if VPC exists: ", vpcID)
|
logrus.Debug("CheckRequirements on VPC : ", vpcID)
|
||||||
_, err := s.EC2.DescribeVpcsWithContext(ctx, &ec2.DescribeVpcsInput{VpcIds: []*string{&vpcID}})
|
output, err := s.EC2.DescribeVpcAttributeWithContext(ctx, &ec2.DescribeVpcAttributeInput{
|
||||||
return err == nil, err
|
VpcId: aws.String(vpcID),
|
||||||
|
Attribute: aws.String("enableDnsSupport"),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !*output.EnableDnsSupport.Value {
|
||||||
|
return fmt.Errorf("VPC %q doesn't have DNS resolution enabled", vpcID)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s sdk) GetDefaultVPC(ctx context.Context) (string, error) {
|
func (s sdk) GetDefaultVPC(ctx context.Context) (string, error) {
|
||||||
|
16
ecs/up.go
16
ecs/up.go
@ -103,23 +103,23 @@ func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b ecsAPIService) GetVPC(ctx context.Context, project *types.Project) (string, error) {
|
func (b ecsAPIService) GetVPC(ctx context.Context, project *types.Project) (string, error) {
|
||||||
|
var vpcID string
|
||||||
//check compose file for custom VPC selected
|
//check compose file for custom VPC selected
|
||||||
if vpc, ok := project.Extensions[extensionVPC]; ok {
|
if vpc, ok := project.Extensions[extensionVPC]; ok {
|
||||||
vpcID := vpc.(string)
|
vpcID = vpc.(string)
|
||||||
ok, err := b.SDK.VpcExists(ctx, vpcID)
|
} else {
|
||||||
|
defaultVPC, err := b.SDK.GetDefaultVPC(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if !ok {
|
vpcID = defaultVPC
|
||||||
return "", fmt.Errorf("VPC does not exist: %s", vpc)
|
|
||||||
}
|
|
||||||
return vpcID, nil
|
|
||||||
}
|
}
|
||||||
defaultVPC, err := b.SDK.GetDefaultVPC(ctx)
|
|
||||||
|
err := b.SDK.CheckVPC(ctx, vpcID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return defaultVPC, nil
|
return vpcID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b ecsAPIService) GetLoadBalancer(ctx context.Context, project *types.Project) (string, error) {
|
func (b ecsAPIService) GetLoadBalancer(ctx context.Context, project *types.Project) (string, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user