I need to deploy AWS resources through Gitlab CI/CD pipeline using AWS cloud formation template.
As part this requirement, I need to pass below json object into a Gitlab CI/CD variable (ssmConfig) and refer this ci/cd variable in .gitlab-ci.yml file in ‘parameter-overrides’ flag while creating (sam deploy command) AWS cloud formation stack.
Json object:
{\"Configurations\":[{\"Identifier\":\"tag:xyz\",\"TagValue\":\"true\",\"MetricName\":\"CPUUtilization\",\"Threshold\":5,\"Namespace\":\"\",\"Period\":3600,\"EvaluationPeriods\":10,\"AlarmActions\":[],\"StopInstance\":false,\"Statistic\":\"Maximum\"},{\"Identifier\":\"instanceId:i-0c12345676e123\",\"MetricName\":\"GPU Usage\",\"Threshold\":5,\"Namespace\":\"P-type Instance Monitor\",\"Period\":3600,\"EvaluationPeriods\":12,\"AlarmActions\":[],\"StopInstance\":false,\"Statistic\":\"Maximum\"}]}
stack creation sample template in .gitlab-ci.yml:
deploy:
stage: deploy
environment:
name: $CI_COMMIT_SLUG
script:
- |
sam deploy --template ./ServiceTemplate-packaged.yaml --no-fail-on-empty-changeset $DONT_EXECUTE_CHANGE_SET --stack-name usage-Stack-$EnvType \
--parameter-overrides vpcEnvType=$vpc_env_type ssmConfig=$ssmConfig \
--capabilities CAPABILITY_NAMED_IAM
ServiceTemplate.yml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: sample infra template
Parameters:
ssmConfig:
Type: String
Description: configuration details
Resources:
----
----
I am getting below error message while running Gitlab ci/cd pipeline.
Error: Invalid value for '--parameter-overrides': Usage","Threshold":5,"Namespace":"P-type is not in valid format. It must look something like 'ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro' or 'KeyPairName=MyKey InstanceType=t1.micro'
Can anyone suggest a work around/solution for this please?