acquia / moonshot

Moonshot: Because releasing services shouldn't be a moonshot!
Apache License 2.0
53 stars 49 forks source link

CPD-7518: Add tags option to create command. #287

Closed marciotoshio closed 2 years ago

marciotoshio commented 2 years ago

Using custom CF template

{
  "Resources": {
    "HelloBucket": {
      "Type": "AWS::S3::Bucket"
    }
  }
}

Create options

➜ cloud-database-api ruby-2.7.3 (CPD-7518-fix) ✗ bundle exec moonshot help create                                              <aws:cloudservicesdev>
Using the Central Model for authentication
Version 2 of the Ruby SDK will enter maintenance mode as of November 20, 2020. To continue receiving service updates and new features, please upgrade to Version 3. More information can be found here: https://aws.amazon.com/blogs/developer/deprecation-schedule-for-aws-sdk-for-ruby-v2/
Using the Central Model for authentication
Usage: moonshot create [options]
    -v, --[no-]verbose               Show debug logging
    -n, --environment=NAME           Which environment to operate on.
        --[no-]interactive-logger    Enable or disable fancy logging
    -t, --token-provider=PROVIDER
        --[no-]interactive           Use interactive prompts for gathering missing configuration.
    -a, --answer-fileFILE            Load Stack Parameters from a YAML file
    -P, --parameterKEY=VALUE         Specify Stack Parameter on the command line
        --[no-]show-all-events       Show all stack events during update
    -p, --parent=PARENT_STACK        Parent stack to import parameters from
        --parents a,b,c              List of parent stacks to import parameters from
    -d, --[no-]deploy                Choose if code should be deployed immediately after the stack is created
        --version VERSION_NAME       Version for initial deployment. If unset, a new development build is created from the local directory
        --template-file=FILE         Override the path to the CloudFormation template.
    -T, --tagsKEY=VALUE              Specify stack tags on the command line

Passing tags to create command

➜ cloud-database-api ruby-2.7.3 (CPD-7518-fix) ✗ bundle exec moonshot create -ncdb-api-dev-toshio-test --template-file ./cloud_formation/test.json -Tstory=CPD-7518 -Tstory-type=bug
Using the Central Model for authentication
Version 2 of the Ruby SDK will enter maintenance mode as of November 20, 2020. To continue receiving service updates and new features, please upgrade to Version 3. More information can be found here: https://aws.amazon.com/blogs/developer/deprecation-schedule-for-aws-sdk-for-ruby-v2/
Using the Central Model for authentication
[ ✓ ] [ 0m 2s ] Created CloudFormation Stack cdb-api-cdb-api-dev-toshio-test.                                                                         
[ ✓ ] [ 0m 36s ] CloudFormation Stack cdb-api-cdb-api-dev-toshio-test successfully created.  

Stack tags

➜ cloud-database-api ruby-2.7.3 (CPD-7518-fix) ✗ aws cloudformation describe-stacks --stack-name cdb-api-cdb-api-dev-toshio-test --query Stacks[].Tags 
[
    [
        {
            "Key": "moonshot_application",
            "Value": "cdb-api"
        },
        {
            "Key": "story-type",
            "Value": "bug"
        },
        {
            "Key": "moonshot_environment",
            "Value": "cdb-api-dev-toshio-test"
        },
        {
            "Key": "story",
            "Value": "CPD-7518"
        }
    ]
]

Bucket tags

➜ cloud-database-api ruby-2.7.3 (CPD-7518-fix) ✗ aws s3api get-bucket-tagging --bucket cdb-api-cdb-api-dev-toshio-test-hellobucket-17hano27ri6xv
Enter MFA code for arn:aws:iam::484203365684:mfa/marcio.toshio: 
{
    "TagSet": [
        {
            "Key": "aws:cloudformation:stack-name",
            "Value": "cdb-api-cdb-api-dev-toshio-test"
        },
        {
            "Key": "aws:cloudformation:stack-id",
            "Value": "arn:aws:cloudformation:us-east-1:672327909798:stack/cdb-api-cdb-api-dev-toshio-test/52e0e700-53cf-11ed-9b68-0aa2623b7b2f"
        },
        {
            "Key": "moonshot_application",
            "Value": "cdb-api"
        },
        {
            "Key": "story-type",
            "Value": "bug"
        },
        {
            "Key": "moonshot_environment",
            "Value": "cdb-api-dev-toshio-test"
        },
        {
            "Key": "aws:cloudformation:logical-id",
            "Value": "HelloBucket"
        },
        {
            "Key": "story",
            "Value": "CPD-7518"
        }
    ]
}
marciotoshio commented 2 years ago

I changed options --tags to --tag