diff --git a/internal/pkg/cli/task_run_test.go b/internal/pkg/cli/task_run_test.go index 1a7c7dd9425..1b56d7cba25 100644 --- a/internal/pkg/cli/task_run_test.go +++ b/internal/pkg/cli/task_run_test.go @@ -7,10 +7,11 @@ import ( "bytes" "errors" "fmt" - "github.com/aws/aws-sdk-go/aws" "path/filepath" "testing" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/copilot-cli/internal/pkg/docker/dockerengine" @@ -157,7 +158,7 @@ func TestTaskRunOpts_Validate(t *testing.T) { basicOpts: defaultOpts, inOS: "OStrich", inArch: "MAD666", - wantedError: errors.New("platform OSTRICH/MAD666 is invalid; valid platforms are: WINDOWS_SERVER_2019_CORE/X86_64, WINDOWS_SERVER_2019_FULL/X86_64, LINUX/X86_64 and LINUX/ARM64"), + wantedError: errors.New("platform OSTRICH/MAD666 is invalid; valid platforms are: WINDOWS_SERVER_2019_CORE/X86_64, WINDOWS_SERVER_2019_FULL/X86_64, WINDOWS_SERVER_2022_CORE/X86_64, WINDOWS_SERVER_2022_FULL/X86_64, LINUX/X86_64 and LINUX/ARM64"), }, "uppercase any lowercase before validating": { basicOpts: basicOpts{ diff --git a/internal/pkg/deploy/cloudformation/stack/transformers.go b/internal/pkg/deploy/cloudformation/stack/transformers.go index eaff3bb3301..975541df955 100644 --- a/internal/pkg/deploy/cloudformation/stack/transformers.go +++ b/internal/pkg/deploy/cloudformation/stack/transformers.go @@ -919,9 +919,13 @@ func convertPlatform(platform manifest.PlatformArgsOrString) template.RuntimePla os := template.OSLinux switch platform.OS() { case manifest.OSWindows, manifest.OSWindowsServer2019Core: - os = template.OSWindowsServerCore + os = template.OSWindowsServer2019Core case manifest.OSWindowsServer2019Full: - os = template.OSWindowsServerFull + os = template.OSWindowsServer2019Full + case manifest.OSWindowsServer2022Core: + os = template.OSWindowsServer2022Core + case manifest.OSWindowsServer2022Full: + os = template.OSWindowsServer2022Full } arch := template.ArchX86 diff --git a/internal/pkg/deploy/cloudformation/stack/transformers_test.go b/internal/pkg/deploy/cloudformation/stack/transformers_test.go index 47718abb25e..b4b56de89e3 100644 --- a/internal/pkg/deploy/cloudformation/stack/transformers_test.go +++ b/internal/pkg/deploy/cloudformation/stack/transformers_test.go @@ -1506,7 +1506,7 @@ func Test_convertPlatform(t *testing.T) { out template.RuntimePlatformOpts }{ "should return empty struct if user did not set a platform field in the manifest": {}, - "should return windows server 2019 full and x86_64 when advanced config specifies full": { + "should return windows server 2019 full and x86_64 when advanced config specifies 2019 full": { in: manifest.PlatformArgsOrString{ PlatformArgs: manifest.PlatformArgs{ OSFamily: aws.String(manifest.OSWindowsServer2019Full), @@ -1514,16 +1514,52 @@ func Test_convertPlatform(t *testing.T) { }, }, out: template.RuntimePlatformOpts{ - OS: template.OSWindowsServerFull, + OS: template.OSWindowsServer2019Full, Arch: template.ArchX86, }, }, - "should return windows server core and x86_64 when platform is 'windows/x86_64'": { + "should return windows server 2019 core and x86_64 when advanced config specifies 2019 core": { + in: manifest.PlatformArgsOrString{ + PlatformArgs: manifest.PlatformArgs{ + OSFamily: aws.String(manifest.OSWindowsServer2019Core), + Arch: aws.String(manifest.ArchX86), + }, + }, + out: template.RuntimePlatformOpts{ + OS: template.OSWindowsServer2019Core, + Arch: template.ArchX86, + }, + }, + "should return windows server 2022 full and x86_64 when advanced config specifies 2022 full": { + in: manifest.PlatformArgsOrString{ + PlatformArgs: manifest.PlatformArgs{ + OSFamily: aws.String(manifest.OSWindowsServer2022Full), + Arch: aws.String(manifest.ArchX86), + }, + }, + out: template.RuntimePlatformOpts{ + OS: template.OSWindowsServer2022Full, + Arch: template.ArchX86, + }, + }, + "should return windows server 2022 core and x86_64 when advanced config specifies 2022 core": { + in: manifest.PlatformArgsOrString{ + PlatformArgs: manifest.PlatformArgs{ + OSFamily: aws.String(manifest.OSWindowsServer2022Core), + Arch: aws.String(manifest.ArchX86), + }, + }, + out: template.RuntimePlatformOpts{ + OS: template.OSWindowsServer2022Core, + Arch: template.ArchX86, + }, + }, + "should return windows server core 2019 and x86_64 when platform is 'windows/x86_64'": { in: manifest.PlatformArgsOrString{ PlatformString: (*manifest.PlatformString)(aws.String("windows/amd64")), }, out: template.RuntimePlatformOpts{ - OS: template.OSWindowsServerCore, + OS: template.OSWindowsServer2019Core, Arch: template.ArchX86, }, }, diff --git a/internal/pkg/manifest/validate_test.go b/internal/pkg/manifest/validate_test.go index b2faa296420..f98b3a841f8 100644 --- a/internal/pkg/manifest/validate_test.go +++ b/internal/pkg/manifest/validate_test.go @@ -1617,7 +1617,7 @@ func TestPlatformArgsOrString_validate(t *testing.T) { Arch: aws.String("amd64"), }, }, - wanted: fmt.Errorf("platform pair ('foo', 'amd64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"), + wanted: fmt.Errorf("platform pair ('foo', 'amd64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"), }, "error if arch is invalid": { in: PlatformArgsOrString{ @@ -1626,7 +1626,7 @@ func TestPlatformArgsOrString_validate(t *testing.T) { Arch: aws.String("bar"), }, }, - wanted: fmt.Errorf("platform pair ('linux', 'bar') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"), + wanted: fmt.Errorf("platform pair ('linux', 'bar') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"), }, "return nil if platform string valid": { in: PlatformArgsOrString{PlatformString: (*PlatformString)(aws.String("linux/amd64"))}, @@ -2541,7 +2541,7 @@ func TestAppRunnerInstanceConfig_validate(t *testing.T) { }, }, }, - wantedError: fmt.Errorf("validate \"platform\": platform pair ('linux', 'leg64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"), + wantedError: fmt.Errorf("validate \"platform\": platform pair ('linux', 'leg64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"), }, "error if App Runner + ARM": { config: AppRunnerInstanceConfig{ diff --git a/internal/pkg/manifest/workload_ecs.go b/internal/pkg/manifest/workload_ecs.go index d082454235e..29c2fa5848c 100644 --- a/internal/pkg/manifest/workload_ecs.go +++ b/internal/pkg/manifest/workload_ecs.go @@ -25,6 +25,8 @@ const ( OSWindows = dockerengine.OSWindows OSWindowsServer2019Core = "windows_server_2019_core" OSWindowsServer2019Full = "windows_server_2019_full" + OSWindowsServer2022Core = "windows_server_2022_core" + OSWindowsServer2022Full = "windows_server_2022_full" ArchAMD64 = dockerengine.ArchAMD64 ArchX86 = dockerengine.ArchX86 @@ -43,7 +45,7 @@ const ( // Platform related settings. var ( defaultPlatform = platformString(OSLinux, ArchAMD64) - windowsOSFamilies = []string{OSWindows, OSWindowsServer2019Core, OSWindowsServer2019Full} + windowsOSFamilies = []string{OSWindows, OSWindowsServer2019Core, OSWindowsServer2019Full, OSWindowsServer2022Core, OSWindowsServer2022Full} validShortPlatforms = []string{ // All of the os/arch combinations that the PlatformString field may accept. dockerengine.PlatformString(OSLinux, ArchAMD64), dockerengine.PlatformString(OSLinux, ArchX86), @@ -63,6 +65,10 @@ var ( {OSFamily: aws.String(OSWindowsServer2019Core), Arch: aws.String(ArchAMD64)}, {OSFamily: aws.String(OSWindowsServer2019Full), Arch: aws.String(ArchX86)}, {OSFamily: aws.String(OSWindowsServer2019Full), Arch: aws.String(ArchAMD64)}, + {OSFamily: aws.String(OSWindowsServer2022Core), Arch: aws.String(ArchX86)}, + {OSFamily: aws.String(OSWindowsServer2022Core), Arch: aws.String(ArchAMD64)}, + {OSFamily: aws.String(OSWindowsServer2022Full), Arch: aws.String(ArchX86)}, + {OSFamily: aws.String(OSWindowsServer2022Full), Arch: aws.String(ArchAMD64)}, } ) diff --git a/internal/pkg/manifest/workload_test.go b/internal/pkg/manifest/workload_test.go index 5bfe7003b3b..764e02b3222 100644 --- a/internal/pkg/manifest/workload_test.go +++ b/internal/pkg/manifest/workload_test.go @@ -466,7 +466,7 @@ func TestPlatformArgsOrString_OS(t *testing.T) { }, wanted: "linux", }, - "should return OS when platform is a map": { + "should return OS when platform is a map 2019 core": { in: &PlatformArgsOrString{ PlatformArgs: PlatformArgs{ OSFamily: aws.String("windows_server_2019_core"), @@ -475,7 +475,7 @@ func TestPlatformArgsOrString_OS(t *testing.T) { }, wanted: "windows_server_2019_core", }, - "should return lowercase OS": { + "should return lowercase OS 2019 core": { in: &PlatformArgsOrString{ PlatformArgs: PlatformArgs{ OSFamily: aws.String("wINdows_sERver_2019_cORe"), @@ -484,6 +484,60 @@ func TestPlatformArgsOrString_OS(t *testing.T) { }, wanted: "windows_server_2019_core", }, + "should return OS when platform is a map 2019 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2019_full"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2019_full", + }, + "should return lowercase OS 2019 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("wINdows_sERver_2019_fUll"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2019_full", + }, + "should return OS when platform is a map 2022 core": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2022_core"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2022_core", + }, + "should return lowercase OS 2022 core": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("wINdows_sERver_2022_cORe"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2022_core", + }, + "should return OS when platform is a map 2022 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2022_full"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2022_full", + }, + "should return lowercase OS 2022 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("wINdows_sERver_2022_fUll"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "windows_server_2022_full", + }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { @@ -503,7 +557,7 @@ func TestPlatformArgsOrString_Arch(t *testing.T) { }, wanted: "arm", }, - "should return arch when platform is a map": { + "should return arch when platform is a map 2019 core": { in: &PlatformArgsOrString{ PlatformArgs: PlatformArgs{ OSFamily: aws.String("windows_server_2019_core"), @@ -512,6 +566,33 @@ func TestPlatformArgsOrString_Arch(t *testing.T) { }, wanted: "x86_64", }, + "should return arch when platform is a map 2019 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2019_full"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "x86_64", + }, + "should return arch when platform is a map 2022 core": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2022_core"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "x86_64", + }, + "should return arch when platform is a map 2022 full": { + in: &PlatformArgsOrString{ + PlatformArgs: PlatformArgs{ + OSFamily: aws.String("windows_server_2022_full"), + Arch: aws.String("x86_64"), + }, + }, + wanted: "x86_64", + }, "should return lowercase arch": { in: &PlatformArgsOrString{ PlatformString: (*PlatformString)(aws.String("windows/aMd64")), diff --git a/internal/pkg/task/config_runner_test.go b/internal/pkg/task/config_runner_test.go index e2f886ba036..eef89d5c2f8 100644 --- a/internal/pkg/task/config_runner_test.go +++ b/internal/pkg/task/config_runner_test.go @@ -254,7 +254,7 @@ func TestNetworkConfigRunner_Run(t *testing.T) { }, }, }, - "successfully kick off task with platform version for windows": { + "successfully kick off task with platform version for windows 2019 core": { count: 1, groupName: "my-task", @@ -283,6 +283,114 @@ func TestNetworkConfigRunner_Run(t *testing.T) { }).Return([]*ecs.Task{&taskWithENI}, nil) }, + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, + "successfully kick off task with platform version for windows 2019 full": { + count: 1, + groupName: "my-task", + + securityGroups: []string{"sg-1", "sg-2"}, + + os: "WINDOWS_SERVER_2019_FULL", + arch: "X86_64", + + mockClusterGetter: func(m *mocks.MockDefaultClusterGetter) { + m.EXPECT().DefaultCluster().Return("cluster-1", nil) + }, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SubnetIDs([]ec2.Filter{ec2.FilterForDefaultVPCSubnets}). + Return([]string{"default-subnet-1", "default-subnet-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"default-subnet-1", "default-subnet-2"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, + "successfully kick off task with platform version for windows 2022 core": { + count: 1, + groupName: "my-task", + + securityGroups: []string{"sg-1", "sg-2"}, + + os: "WINDOWS_SERVER_2022_CORE", + arch: "X86_64", + + mockClusterGetter: func(m *mocks.MockDefaultClusterGetter) { + m.EXPECT().DefaultCluster().Return("cluster-1", nil) + }, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SubnetIDs([]ec2.Filter{ec2.FilterForDefaultVPCSubnets}). + Return([]string{"default-subnet-1", "default-subnet-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"default-subnet-1", "default-subnet-2"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, + "successfully kick off task with platform version for windows 2022 full": { + count: 1, + groupName: "my-task", + + securityGroups: []string{"sg-1", "sg-2"}, + + os: "WINDOWS_SERVER_2022_FULL", + arch: "X86_64", + + mockClusterGetter: func(m *mocks.MockDefaultClusterGetter) { + m.EXPECT().DefaultCluster().Return("cluster-1", nil) + }, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SubnetIDs([]ec2.Filter{ec2.FilterForDefaultVPCSubnets}). + Return([]string{"default-subnet-1", "default-subnet-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"default-subnet-1", "default-subnet-2"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + wantedTasks: []*Task{ { TaskARN: "task-1", diff --git a/internal/pkg/task/env_runner_test.go b/internal/pkg/task/env_runner_test.go index a090c047795..059c79f1554 100644 --- a/internal/pkg/task/env_runner_test.go +++ b/internal/pkg/task/env_runner_test.go @@ -235,7 +235,37 @@ func TestEnvRunner_Run(t *testing.T) { }, }, }, - "run in env with windows os success": { + "run in env with windows os success 2019 core": { + count: 1, + groupName: "my-task", + os: "WINDOWS_SERVER_2019_CORE", + arch: "X86_64", + + MockClusterGetter: mockClusterGetter, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SecurityGroups(filtersForSecurityGroup).Return([]string{"sg-1", "sg-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"subnet-0789ab", "subnet-0123cd"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + mockEnvironmentDescriber: mockEnvironmentDescriberValid, + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, + "run in env with windows os success 2019 full": { count: 1, groupName: "my-task", os: "WINDOWS_SERVER_2019_FULL", @@ -265,6 +295,66 @@ func TestEnvRunner_Run(t *testing.T) { }, }, }, + "run in env with windows os success 2022 core": { + count: 1, + groupName: "my-task", + os: "WINDOWS_SERVER_2022_CORE", + arch: "X86_64", + + MockClusterGetter: mockClusterGetter, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SecurityGroups(filtersForSecurityGroup).Return([]string{"sg-1", "sg-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"subnet-0789ab", "subnet-0123cd"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + mockEnvironmentDescriber: mockEnvironmentDescriberValid, + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, + "run in env with windows os success 2022 full": { + count: 1, + groupName: "my-task", + os: "WINDOWS_SERVER_2022_FULL", + arch: "X86_64", + + MockClusterGetter: mockClusterGetter, + MockVPCGetter: func(m *mocks.MockVPCGetter) { + m.EXPECT().SecurityGroups(filtersForSecurityGroup).Return([]string{"sg-1", "sg-2"}, nil) + }, + mockStarter: func(m *mocks.MockRunner) { + m.EXPECT().RunTask(ecs.RunTaskInput{ + Cluster: "cluster-1", + Count: 1, + Subnets: []string{"subnet-0789ab", "subnet-0123cd"}, + SecurityGroups: []string{"sg-1", "sg-2"}, + TaskFamilyName: taskFamilyName("my-task"), + StartedBy: startedBy, + PlatformVersion: "1.0.0", + EnableExec: true, + }).Return([]*ecs.Task{&taskWithENI}, nil) + }, + mockEnvironmentDescriber: mockEnvironmentDescriberValid, + wantedTasks: []*Task{ + { + TaskARN: "task-1", + ENI: "eni-1", + }, + }, + }, "eni information not found for several tasks": { count: 1, groupName: "my-task", diff --git a/internal/pkg/task/task.go b/internal/pkg/task/task.go index c10247e9f79..5da52f24949 100644 --- a/internal/pkg/task/task.go +++ b/internal/pkg/task/task.go @@ -6,15 +6,15 @@ package task import ( "fmt" - "github.com/aws/copilot-cli/internal/pkg/template" "time" - "github.com/aws/copilot-cli/internal/pkg/docker/dockerengine" - - "github.com/aws/aws-sdk-go/aws" "github.com/aws/copilot-cli/internal/pkg/aws/ec2" "github.com/aws/copilot-cli/internal/pkg/aws/ecs" "github.com/aws/copilot-cli/internal/pkg/describe" + "github.com/aws/copilot-cli/internal/pkg/docker/dockerengine" + "github.com/aws/copilot-cli/internal/pkg/template" + + "github.com/aws/aws-sdk-go/aws" ) // VPCGetter wraps methods of getting VPC info. @@ -59,17 +59,25 @@ const ( startedBy = "copilot-task" // Platform options. - osLinux = template.OSLinux - osWindowsServerFull = template.OSWindowsServerFull - osWindowsServerCore = template.OSWindowsServerCore + osLinux = template.OSLinux + osWindowsServer2019Full = template.OSWindowsServer2019Full + osWindowsServer2019Core = template.OSWindowsServer2019Core + osWindowsServer2022Full = template.OSWindowsServer2022Full + osWindowsServer2022Core = template.OSWindowsServer2022Core archX86 = template.ArchX86 archARM64 = template.ArchARM64 ) var ( - ValidWindowsOSs = []string{osWindowsServerCore, osWindowsServerFull} - ValidCFNPlatforms = []string{dockerengine.PlatformString(osWindowsServerCore, archX86), dockerengine.PlatformString(osWindowsServerFull, archX86), dockerengine.PlatformString(osLinux, archX86), dockerengine.PlatformString(osLinux, archARM64)} + ValidWindowsOSs = []string{osWindowsServer2019Core, osWindowsServer2019Full, osWindowsServer2022Core, osWindowsServer2022Full} + ValidCFNPlatforms = []string{ + dockerengine.PlatformString(osWindowsServer2019Core, archX86), + dockerengine.PlatformString(osWindowsServer2019Full, archX86), + dockerengine.PlatformString(osWindowsServer2022Core, archX86), + dockerengine.PlatformString(osWindowsServer2022Full, archX86), + dockerengine.PlatformString(osLinux, archX86), + dockerengine.PlatformString(osLinux, archARM64)} fmtTaskFamilyName = "copilot-%s" ) diff --git a/internal/pkg/template/workload.go b/internal/pkg/template/workload.go index fc9cf8cfcad..49b221409f3 100644 --- a/internal/pkg/template/workload.go +++ b/internal/pkg/template/workload.go @@ -45,9 +45,13 @@ const ( PrivateSubnetsPlacement = "PrivateSubnets" // RuntimePlatform configuration. - OSLinux = "LINUX" - OSWindowsServerFull = "WINDOWS_SERVER_2019_FULL" - OSWindowsServerCore = "WINDOWS_SERVER_2019_CORE" + OSLinux = "LINUX" + OSWindowsServerFull = OSWindowsServer2019Full // Alias 2019 as Default WindowsSever Full platform. + OSWindowsServerCore = OSWindowsServer2019Core // Alias 2019 as Default WindowsSever Core platform. + OSWindowsServer2019Full = "WINDOWS_SERVER_2019_FULL" + OSWindowsServer2019Core = "WINDOWS_SERVER_2019_CORE" + OSWindowsServer2022Full = "WINDOWS_SERVER_2022_FULL" + OSWindowsServer2022Core = "WINDOWS_SERVER_2022_CORE" ArchX86 = "X86_64" ArchARM64 = "ARM64" @@ -96,7 +100,7 @@ var ( // Operating systems to determine Fargate platform versions. osFamiliesForPV100 = []string{ - OSWindowsServerFull, OSWindowsServerCore, + OSWindowsServer2019Full, OSWindowsServer2019Core, OSWindowsServer2022Full, OSWindowsServer2022Core, } ) diff --git a/internal/pkg/template/workload_test.go b/internal/pkg/template/workload_test.go index 48743a4804b..d46809907e4 100644 --- a/internal/pkg/template/workload_test.go +++ b/internal/pkg/template/workload_test.go @@ -171,13 +171,34 @@ func TestRuntimePlatformOpts_Version(t *testing.T) { }, wantedPV: "LATEST", }, - "should return 1.0.0 for windows containers": { + "should return 1.0.0 for windows containers 2019 Core": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2019_CORE", + Arch: "X86_64", + }, + wantedPV: "1.0.0", + }, + "should return 1.0.0 for windows containers 2019 Full": { in: RuntimePlatformOpts{ OS: "WINDOWS_SERVER_2019_FULL", Arch: "X86_64", }, wantedPV: "1.0.0", }, + "should return 1.0.0 for windows containers 2022 Core": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2022_CORE", + Arch: "X86_64", + }, + wantedPV: "1.0.0", + }, + "should return 1.0.0 for windows containers 2022 Full": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2022_FULL", + Arch: "X86_64", + }, + wantedPV: "1.0.0", + }, } for name, tc := range testCases { @@ -202,12 +223,30 @@ func TestRuntimePlatformOpts_IsDefault(t *testing.T) { }, wanted: true, }, - "should return false for windows containers": { + "should return false for windows containers 2019 Core": { in: RuntimePlatformOpts{ OS: "WINDOWS_SERVER_2019_CORE", Arch: "X86_64", }, }, + "should return false for windows containers 2019 Full": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2019_FULL", + Arch: "X86_64", + }, + }, + "should return false for windows containers 2022 Core": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2022_CORE", + Arch: "X86_64", + }, + }, + "should return false for windows containers 2022 Full": { + in: RuntimePlatformOpts{ + OS: "WINDOWS_SERVER_2022_FULL", + Arch: "X86_64", + }, + }, } for name, tc := range testCases { diff --git a/site/content/docs/commands/task-run.en.md b/site/content/docs/commands/task-run.en.md index fc0f2fd39a5..76d91c32202 100644 --- a/site/content/docs/commands/task-run.en.md +++ b/site/content/docs/commands/task-run.en.md @@ -112,3 +112,8 @@ Run a Windows task with the minimum cpu and memory values. ```console $ copilot task run --platform-os WINDOWS_SERVER_2019_CORE --platform-arch X86_64 --cpu 1024 --memory 2048 ``` + +Run a Windows 2022 task with the minimum cpu and memory values. +```console +$ copilot task run --platform-os WINDOWS_SERVER_2022_CORE --platform-arch X86_64 --cpu 1024 --memory 2048 +``` \ No newline at end of file diff --git a/site/content/docs/commands/task-run.ja.md b/site/content/docs/commands/task-run.ja.md index 38f0e3a4583..dcb8ed8e22b 100644 --- a/site/content/docs/commands/task-run.ja.md +++ b/site/content/docs/commands/task-run.ja.md @@ -108,7 +108,12 @@ $ copilot task run --subnets subnet-123,subnet-456 --security-groups sg-123,sg-4 $ copilot task run --command "python migrate-script.py" ``` -Windows タスクを最小のCPUとメモリで実行します。 +Windows 2019 タスクを最小の CPU とメモリで実行します。 ```console $ copilot task run --platform-os WINDOWS_SERVER_2019_CORE --platform-arch X86_64 --cpu 1024 --memory 2048 ``` + +Windows 2022 タスクを最小の CPU とメモリで実行します。 +```console +$ copilot task run --platform-os WINDOWS_SERVER_2022_CORE --platform-arch X86_64 --cpu 1024 --memory 2048 +``` \ No newline at end of file diff --git a/site/content/docs/include/platform.en.md b/site/content/docs/include/platform.en.md index 100d5227339..e4a8286f23f 100644 --- a/site/content/docs/include/platform.en.md +++ b/site/content/docs/include/platform.en.md @@ -13,3 +13,13 @@ platform: osfamily: windows_server_2019_full architecture: x86_64 ``` +```yaml +platform: + osfamily: windows_server_2022_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_full + architecture: x86_64 +``` diff --git a/site/content/docs/include/platform.ja.md b/site/content/docs/include/platform.ja.md index d2043c4ea14..c94b4f38bb6 100644 --- a/site/content/docs/include/platform.ja.md +++ b/site/content/docs/include/platform.ja.md @@ -18,3 +18,18 @@ platform: osfamily: windows_server_2019_full architecture: x86_64 ``` +```yaml +platform: + osfamily: windows_server_2019_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_full + architecture: x86_64 +``` diff --git a/site/content/docs/manifest/scheduled-job.en.md b/site/content/docs/manifest/scheduled-job.en.md index 4f18b3321cc..1bc333e7532 100644 --- a/site/content/docs/manifest/scheduled-job.en.md +++ b/site/content/docs/manifest/scheduled-job.en.md @@ -120,6 +120,21 @@ platform: osfamily: windows_server_2019_full architecture: x86_64 ``` +```yaml +platform: + osfamily: windows_server_2019_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_full + architecture: x86_64 +```
diff --git a/site/content/docs/manifest/scheduled-job.ja.md b/site/content/docs/manifest/scheduled-job.ja.md index 4fd168cf7eb..ffc2aeeeda9 100644 --- a/site/content/docs/manifest/scheduled-job.ja.md +++ b/site/content/docs/manifest/scheduled-job.ja.md @@ -123,6 +123,21 @@ platform: osfamily: windows_server_2019_full architecture: x86_64 ``` +```yaml +platform: + osfamily: windows_server_2019_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_core + architecture: x86_64 +``` +```yaml +platform: + osfamily: windows_server_2022_full + architecture: x86_64 +```