jenkinsamazon-elastic-beanstalkaws-cloudformation

An error occurred (InvalidParameterValue) when calling the CreateEnvironment operation: Tag key 'Name' is reserved


Im receiving following error when trying to deploy spring boot application using Jenkins to AWS Elastic beanstalk. This used to get deployed without an issue, but this error has started to occur recently.

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the CreateEnvironment operation: Tag key 'Name' is reserved and can't be modified.

Below is the configurations used to setup the cloudformation stack.

[
    {
      "OptionName": "ELBSubnets",
      "Namespace": "aws:ec2:vpc",
      "ExportName": "apis-nonprod-vpc-apis-sit-vpc::PublicSubnets"
    },
    {
      "OptionName": "Subnets",
      "ResourceName": "AWSEBAutoScalingGroup",
      "Namespace": "aws:ec2:vpc",
      "ExportName": "apis-nonprod-vpc-apis-sit-vpc::PrivateSubnets"
    },
    {
      "OptionName": "VPCId",
      "ResourceName": "AWSEBLoadBalancerSecurityGroup",
      "Namespace": "aws:ec2:vpc",
      "ExportName": "apis-nonprod-vpc-apis-sit-vpc::VpcId"
    },
    {
      "OptionName": "EC2KeyName",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "Value": "develop-apis-sit"
    },
    {
      "Namespace": "aws:elasticbeanstalk:customoption",
      "OptionName": "SecretBucket",
      "Value": "apis-sit-secrets"
    },
    {
      "OptionName": "spring.profiles.active",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Value": "sit"
    },
    {
      "OptionName": "IamInstanceProfile",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "ExportName": "app-dev::EbsInstanceIamInstanceProfileName"
    },
    {
      "OptionName": "SSMParameterNamespace",
      "Namespace": "aws:elasticbeanstalk:customoption",
      "Value": "app-dev"
    },
    {
      "OptionName": "BatchSize",
      "Namespace": "aws:elasticbeanstalk:command",
      "Value": "1"
    },
    {
      "OptionName": "AppDynamicsAgentBucket",
      "Namespace": "aws:elasticbeanstalk:customoption",
      "Value": "appdynamics-agents-nonprod"
    }
]

Solution

  • Name is one of the few tags that Elastic Beanstalk applies by default to your environment and you can't edit these default tags.

    From AWS Doc:

    Elastic Beanstalk applies environment tags to the environment resource itself, as well as to other AWS resources that Elastic Beanstalk creates for the environment.

    By default, Elastic Beanstalk applies a few tags to your environment:

    • elasticbeanstalk:environment-name – The name of the environment.
    • elasticbeanstalk:environment-id – The environment ID.
    • Name – Also the name of the environment. Name is used in the Amazon EC2 dashboard to identify and sort resources.

    You can't edit these default tags.