aws-sdk-go-v2
aws-sdk-go-v2 copied to clipboard
[Proton] Shouldn't "CreateService" operation keep consistency with AWS CLI regarding Spec/YAML validation?
Confirm by changing [ ] to [x] below:
- [X] I've gone though the API reference
- [X] I've checked AWS Forums and StackOverflow for answers
Describe the question To keep it short, I've been trying to use the SDK to create a Proton Service from a given event, generating the Spec file dynamically; but no success so far, as I'm constantly getting the following error:
operation error Proton: CreateService, https response error StatusCode: 400, RequestID: e07868d6-51ef-4cfa-8622-4d2b4c41f18b,
ValidationException: The provided Service Spec file was not correctly formatted.
Please check that it is valid yaml according to the Spec definition.
I'm creating the YAMLs by using os.WriteFile
(from a marshaled struct using go-yaml
), which creates a .yaml with application/x-yaml
Mime-Type; reading the docs I reckon the Spec file should, in fact, be a application/yaml
- so I'm still not sure if it encompass the type variants.
Either way I decided to test with a "original" Spec file, downloaded from a working Proton Service (Service > Actions > Download Spec) - and to my surprise I got the same error.
I decided to use AWS CLI to create a service using one of the dynamically generated files - and it worked!
So... Shouldn't the SDK have the same behavior?
Info
Spec file (dynamically generated and used with AWS CLI):
proton: ServiceSpec
pipeline:
vars: API_URL https://api-chatops.[removed]
instances:
- name: front-1631401672
environment: staging
spec:
subdomain: chatops
image: public.ecr.aws/lts/nginx:latest
health: /check-status
task_size: x-small
max_capacity: 1
port: 3000
env: production
Snippet
Operation call:
Click to expand!
func DeployService(svc *service.Spec) (err error) {
ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Minute)
defer cancel()
fmt.Println("Realizando deploy do serviço", svc.Name)
params := &proton.CreateServiceInput{
Name: aws.String(svc.Name),
Spec: aws.String(svc.ManifestFile),
TemplateMajorVersion: aws.String("1"),
TemplateMinorVersion: aws.String("11"),
TemplateName: aws.String("webapp-ci"),
BranchName: aws.String(svc.Branch),
Description: aws.String(svc.Description),
RepositoryConnectionArn: aws.String([removed]),
RepositoryId: aws.String(svc.Repository),
}
out, err := client.CreateService(ctx, params)
if err != nil {
return err
}
fmt.Println("Serviço", out.Service.Arn, "enviado com status", out.Service.Status, out.Service.StatusMessage)
return
}
CLI command
aws proton create-service --name test --branch-name "master" --template-major-version "1" --template-minor-version "11" --template-name "webapp-ci" --repository-connection-arn "[removed]" --repository-id "[removed]" --spec "file://front-1631401672.yml"
Versions
AWS SDK: v1.9.0 Proton Service: v1.3.0 AWS CLI: aws-cli/2.2.32 Python/3.8.8 Linux/5.13.13-arch1-1 exe/x86_64.arch prompt/off
Go: go version go1.17 linux/amd64
I guess this might sound a bit dumb, but I managed to get it working. How? Well... by setting the Spec
field with the marshalled YAML without an "intermediary" file.
I still would like to keep the issue open by now though, because what led me to believe a file was necessary is the wording in the documentation (that also appears in JS docs):
A link to a spec file that provides inputs as defined in the service template bundle schema file. The spec file is in YAML format. Don’t include pipeline inputs in the spec if your service template doesn’t include a service pipeline. For more information, see Create a service (https://docs.aws.amazon.com/proton/latest/adminguide/ag-create-svc.html.html) in the AWS Proton Administrator Guide and Create a service (https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-create.html) in the AWS Proton User Guide.
This value conforms to the media type: application/yaml
Should I open another issue about the docs improvement or keep this one?
Hi @jefersonhuan , Thanks for pointing this out, we can keep this one open I'll just re-label it and yea we'll look into changing the wording to be a bit clearer.
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
I'm getting the same error when trying to "aws proton create-environment", and passing a spec file directly downloaded from AWS samples:
An error occurred (ValidationException) when calling the CreateEnvironment operation: The provided Environment Spec file was not correctly formatted. Please check that it is valid yaml according to the Spec definition.
A dozen different yaml checkers confirm that the yaml in the file is vaid, but AWS CLI disagrees.