in internal/pkg/deploy/cloudformation/stack/workload.go [410:506]
func (w *appRunnerWkld) Parameters() ([]*cloudformation.Parameter, error) {
wkldParameters, err := w.wkld.Parameters()
if err != nil {
return nil, err
}
var img string
if w.image != nil {
img = w.image.GetLocation()
}
if image, ok := w.rc.PushedImages[w.name]; ok {
img = image.URI()
}
// 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 {
return nil, fmt.Errorf("field `image.port` is required for Request Driven Web Services")
}
if w.instanceConfig.CPU == nil {
return nil, fmt.Errorf("field `cpu` is required for Request Driven Web Services")
}
if w.instanceConfig.Memory == nil {
return nil, fmt.Errorf("field `memory` is required for Request Driven Web Services")
}
appRunnerParameters := []*cloudformation.Parameter{
{
ParameterKey: aws.String(RDWkldImageRepositoryType),
ParameterValue: aws.String(imageRepositoryType),
},
{
ParameterKey: aws.String(WorkloadContainerPortParamKey),
ParameterValue: aws.String(strconv.Itoa(int(aws.Uint16Value(w.imageConfig.Port)))),
},
{
ParameterKey: aws.String(RDWkldInstanceCPUParamKey),
ParameterValue: aws.String(strconv.Itoa(aws.IntValue(w.instanceConfig.CPU))),
},
{
ParameterKey: aws.String(RDWkldInstanceMemoryParamKey),
ParameterValue: aws.String(strconv.Itoa(aws.IntValue(w.instanceConfig.Memory))),
},
}
// Optional HealthCheckPath parameter
if w.healthCheckConfig.Path() != nil {
appRunnerParameters = append(appRunnerParameters, &cloudformation.Parameter{
ParameterKey: aws.String(RDWkldHealthCheckPathParamKey),
ParameterValue: aws.String(*w.healthCheckConfig.Path()),
})
}
// Optional HealthCheckInterval parameter
if w.healthCheckConfig.Advanced.Interval != nil {
appRunnerParameters = append(appRunnerParameters, &cloudformation.Parameter{
ParameterKey: aws.String(RDWkldHealthCheckIntervalParamKey),
ParameterValue: aws.String(strconv.Itoa(int(w.healthCheckConfig.Advanced.Interval.Seconds()))),
})
}
// Optional HealthCheckTimeout parameter
if w.healthCheckConfig.Advanced.Timeout != nil {
appRunnerParameters = append(appRunnerParameters, &cloudformation.Parameter{
ParameterKey: aws.String(RDWkldHealthCheckTimeoutParamKey),
ParameterValue: aws.String(strconv.Itoa(int(w.healthCheckConfig.Advanced.Timeout.Seconds()))),
})
}
// Optional HealthCheckHealthyThreshold parameter
if w.healthCheckConfig.Advanced.HealthyThreshold != nil {
appRunnerParameters = append(appRunnerParameters, &cloudformation.Parameter{
ParameterKey: aws.String(RDWkldHealthCheckHealthyThresholdParamKey),
ParameterValue: aws.String(strconv.Itoa(int(*w.healthCheckConfig.Advanced.HealthyThreshold))),
})
}
// Optional HealthCheckUnhealthyThreshold parameter
if w.healthCheckConfig.Advanced.UnhealthyThreshold != nil {
appRunnerParameters = append(appRunnerParameters, &cloudformation.Parameter{
ParameterKey: aws.String(RDWkldHealthCheckUnhealthyThresholdParamKey),
ParameterValue: aws.String(strconv.Itoa(int(*w.healthCheckConfig.Advanced.UnhealthyThreshold))),
})
}
return append(wkldParameters, appRunnerParameters...), nil
}