Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Tags argument for CloudFormation (#81)
Browse files Browse the repository at this point in the history
* --tags argument for CloudFormation
  • Loading branch information
nikita-paskal-dynatrace authored Feb 10, 2023
1 parent 9949b28 commit c12ffe1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dynatrace-aws-logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ case $MAIN_OPTION in

function print_help_deploy {
printf "
usage: dynatrace-aws-logs.sh deploy --target-url TARGET_URL --target-api-token TARGET_API_TOKEN [--use-existing-active-gate {true|false}] [--target-paas-token TARGET_PAAS_TOKEN] [--require-valid-certificate {true|false}] [--stack-name STACK_NAME]
usage: dynatrace-aws-logs.sh deploy --target-url TARGET_URL --target-api-token TARGET_API_TOKEN [--use-existing-active-gate {true|false}] [--target-paas-token TARGET_PAAS_TOKEN] [--require-valid-certificate {true|false}] [--stack-name STACK_NAME] [--tags <value> [<value>...] ]
arguments:
-h, --help show this help message and exit
Expand All @@ -84,6 +84,9 @@ arguments:
--max-log-length MAX_LOG_CONTENT_LENGTH
Optional, defaults to 8192. Defines the max log length after which a log will be truncated.
For values over 8192 there's also a change in Dynatrace settings needed. For that you need to contact Dynatrace One.
--tags TAGS
Optional. A list of tags to associate with the stack that is created or updated.
Syntax: TagKey1=TagValue1 TagKey2=TagValue2 ...
"
}

Expand Down Expand Up @@ -203,6 +206,18 @@ EOF
shift;shift;
;;

"--tags")
shift;
while (( "$#" )); do
if [[ $1 == "--"* ]]; then
break
fi
TAGS+=("$1")
shift
TAGS_LIST=${TAGS[*]}
done;
;;

"-h" | "--help")
print_help_deploy
shift; exit 0
Expand All @@ -220,6 +235,7 @@ EOF
if [ -z "$STACK_NAME" ]; then STACK_NAME=$DEFAULT_STACK_NAME; fi
if [ -z "$USE_EXISTING_ACTIVE_GATE" ]; then USE_EXISTING_ACTIVE_GATE="true"; fi
if [ -z "$MAX_LOG_CONTENT_LENGTH" ]; then MAX_LOG_CONTENT_LENGTH=8192; fi
if (( ${#TAGS_LIST[@]} == 0 )); then unset $TAGS; else TAGS="--tags $TAGS_LIST"; fi

if [[ "$REQUIRE_VALID_CERTIFICATE" != "true" ]] && [[ "$REQUIRE_VALID_CERTIFICATE" != "false" ]];
then echo "Invalid value for parameter --require-valid-certificate. Provide 'true' or 'false'"; print_help_deploy; exit 1; fi
Expand Down Expand Up @@ -269,7 +285,7 @@ EOF
aws cloudformation deploy --stack "$STACK_NAME" --template-file "$TEMPLATE_FILE" --capabilities CAPABILITY_IAM \
--parameter-overrides DynatraceEnvironmentUrl="$TARGET_URL" DynatraceApiKey="$TARGET_API_TOKEN" VerifySSLTargetActiveGate="$REQUIRE_VALID_CERTIFICATE" \
UseExistingActiveGate="$USE_EXISTING_ACTIVE_GATE" TenantId="$TENANT_ID" DynatracePaasToken="$TARGET_PAAS_TOKEN" \
MaxLogContentLength="$MAX_LOG_CONTENT_LENGTH" --no-fail-on-empty-changeset
MaxLogContentLength="$MAX_LOG_CONTENT_LENGTH" --no-fail-on-empty-changeset $TAGS

LAMBDA_ARN=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" \
--query "Stacks[0].Outputs[?OutputKey=='LambdaArn'][OutputValue]" --output text)
Expand Down

0 comments on commit c12ffe1

Please sign in to comment.