Skip to content

Commit

Permalink
Fix bug in test utility: Force public ip so container images can be p…
Browse files Browse the repository at this point in the history
…ulled
  • Loading branch information
yorinasub17 committed Apr 11, 2019
1 parent 675688e commit d473abd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions aws/ecs_utils_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
gruntworkerrors "github.com/gruntwork-io/gruntwork-cli/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/gruntwork-io/cloud-nuke/logging"
)

// We black list us-east-1e because this zone is frequently out of capacity
Expand All @@ -37,6 +39,8 @@ func getRandomFargateSupportedRegion() string {
}

func createEcsFargateCluster(t *testing.T, awsSession *session.Session, name string) ecs.Cluster {
logging.Logger.Infof("Creating ECS cluster %s in region %s", name, *awsSession.Config.Region)

svc := ecs.New(awsSession)
result, err := svc.CreateCluster(&ecs.CreateClusterInput{ClusterName: awsgo.String(name)})
if err != nil {
Expand Down Expand Up @@ -294,11 +298,16 @@ func getVpcConfiguration(awsSession *session.Session) (ecs.AwsVpcConfiguration,
}
var subnetIds []*string
for _, subnet := range subnets.Subnets {
if !collections.ListContainsElement(AvailabilityZoneBlackList, awsgo.StringValue(subnet.AvailabilityZone)) {
// Only use public subnets for testing simplicity
if !collections.ListContainsElement(AvailabilityZoneBlackList, awsgo.StringValue(subnet.AvailabilityZone)) && awsgo.BoolValue(subnet.MapPublicIpOnLaunch) {
subnetIds = append(subnetIds, subnet.SubnetId)
}
}
return ecs.AwsVpcConfiguration{Subnets: subnetIds}, nil
vpcConfig := ecs.AwsVpcConfiguration{
Subnets: subnetIds,
AssignPublicIp: awsgo.String(ecs.AssignPublicIpEnabled),
}
return vpcConfig, nil
}

const ECS_ASSUME_ROLE_POLICY = `{
Expand Down

0 comments on commit d473abd

Please sign in to comment.