Skip to content

Commit

Permalink
Add awslogs-endpoint for isolated regions when creating containers
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekchaudhry committed Jul 26, 2024
1 parent 51c7484 commit d5ab4ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions agent/engine/docker_task_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1876,10 +1876,10 @@ func (engine *DockerTaskEngine) createContainer(task *apitask.Task, container *a
}
}

// This is a short term solution only for specific regions until AWS SDK Go is upgraded to V2
// This is a short term solution only for specific regions
if hostConfig.LogConfig.Type == logDriverTypeAwslogs {
region := engine.cfg.AWSRegion
if region == "eu-isoe-west-1" || region == "us-isof-south-1" || region == "us-isof-east-1" {
if region == "us-isob-east-1" || region == "us-iso-east-1" || region == "us-iso-west-1" || region == "eu-isoe-west-1" || region == "us-isof-south-1" || region == "us-isof-east-1" {
endpoint := ""
dnsSuffix := ""
partition, ok := ep.PartitionForRegion(ep.DefaultPartitions(), region)
Expand Down
21 changes: 18 additions & 3 deletions agent/engine/docker_task_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ func TestTaskSecretsEnvironmentVariables(t *testing.T) {
mockSSMClient := mock_ssmiface.NewMockSSMClient(ctrl)

ssmRequirements := map[string][]apicontainer.Secret{
ssmSecretRegion: []apicontainer.Secret{
ssmSecretRegion: {
tc.ssmSecret,
},
}
Expand Down Expand Up @@ -2904,7 +2904,7 @@ func TestTaskSecretsEnvironmentVariables(t *testing.T) {
ssmClientOutput := &ssm.GetParametersOutput{
InvalidParameters: []*string{},
Parameters: []*ssm.Parameter{
&ssm.Parameter{
{
Name: aws.String(ssmSecretValueFrom),
Value: aws.String(ssmSecretRetrievedValue),
},
Expand Down Expand Up @@ -2972,6 +2972,21 @@ func TestCreateContainerAwslogsLogDriver(t *testing.T) {
region: "us-isof-east-1",
expectedLogConfigEndpoint: "https://logs.us-isof-east-1.csp.hci.ic.gov",
},
{
name: "test container that uses awslogs log driver in LCK",
region: "us-isob-east-1",
expectedLogConfigEndpoint: "https://logs.us-isob-east-1.sc2s.sgov.gov",
},
{
name: "test container that uses awslogs log driver in DCA",
region: "us-isof-south-1",
expectedLogConfigEndpoint: "https://logs.us-iso-east-1.c2s.ic.gov",
},
{
name: "test container that uses awslogs log driver in APA",
region: "us-isof-east-1",
expectedLogConfigEndpoint: "https://logs.us-iso-west-1.c2s.ic.gov",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -3507,7 +3522,7 @@ func TestStartFirelensContainerRetryForContainerIP(t *testing.T) {
IPAddress: networkBridgeIP,
},
Networks: map[string]*network.EndpointSettings{
apitask.BridgeNetworkMode: &network.EndpointSettings{
apitask.BridgeNetworkMode: {
IPAddress: networkBridgeIP,
},
},
Expand Down

0 comments on commit d5ab4ad

Please sign in to comment.