diff --git a/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go b/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go index efbfc520b88..fb932c82f17 100644 --- a/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go +++ b/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go @@ -421,6 +421,53 @@ func TestRequestDrivenWebService_Parameters(t *testing.T) { ParameterValue: aws.String("1024"), }}, }, + "skip checking image repository type when `image.build` is specified": { + imageConfig: manifest.ImageWithPort{ + Image: manifest.Image{ + ImageLocationOrBuild: manifest.ImageLocationOrBuild{ + Build: manifest.BuildArgsOrString{ + BuildString: aws.String("./frontend/Dockerfile"), + }, + }, + }, + Port: aws.Uint16(80), + }, + instanceConfig: manifest.AppRunnerInstanceConfig{ + CPU: aws.Int(1024), + Memory: aws.Int(1024), + }, + wantedParams: []*cloudformation.Parameter{{ + ParameterKey: aws.String("AppName"), + ParameterValue: aws.String("phonetool"), + }, { + ParameterKey: aws.String("EnvName"), + ParameterValue: aws.String("test"), + }, { + ParameterKey: aws.String("WorkloadName"), + ParameterValue: aws.String("frontend"), + }, { + ParameterKey: aws.String("ContainerImage"), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String("AddonsTemplateURL"), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(WorkloadArtifactKeyARNParamKey), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(RDWkldImageRepositoryType), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(WorkloadContainerPortParamKey), + ParameterValue: aws.String("80"), + }, { + ParameterKey: aws.String(RDWkldInstanceCPUParamKey), + ParameterValue: aws.String("1024"), + }, { + ParameterKey: aws.String(RDWkldInstanceMemoryParamKey), + ParameterValue: aws.String("1024"), + }}, + }, "error when port unspecified": { imageConfig: manifest.ImageWithPort{ Image: manifest.Image{ diff --git a/internal/pkg/deploy/cloudformation/stack/workload.go b/internal/pkg/deploy/cloudformation/stack/workload.go index e28450bb284..6a4890b4742 100644 --- a/internal/pkg/deploy/cloudformation/stack/workload.go +++ b/internal/pkg/deploy/cloudformation/stack/workload.go @@ -420,9 +420,15 @@ func (w *appRunnerWkld) Parameters() ([]*cloudformation.Parameter, error) { img = image.URI() } - imageRepositoryType, err := apprunner.DetermineImageRepositoryType(img) - if err != nil { - return nil, fmt.Errorf("determine image repository type: %w", err) + // This happens only when `copilot svc package` is used with out `--upload-assets` flag. + // In case of `image.build` is used, then `w.rc.PushedImages` will be nil, which leads to `img` to be empty. + // Skip the image repository type check in that case. + var imageRepositoryType string + if img != "" { + imageRepositoryType, err = apprunner.DetermineImageRepositoryType(img) + if err != nil { + return nil, fmt.Errorf("determine image repository type: %w", err) + } } if w.imageConfig.Port == nil {