From bbc236165d2fe6eea466a2b4788ea2f45dee528c Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Fri, 24 May 2024 15:08:50 +0530 Subject: [PATCH] Remove EC2_ENV variable --- .github/workflows/main-dev-deploy.yml | 1 + .github/workflows/main-prd-deploy.yml | 3 ++- .../codedeploy/contents/naksha-hub/set-app-params.sh | 2 +- .../codedeploy/contents/naksha-hub/set-instance-params.sh | 6 +++--- deployment/codedeploy/contents/naksha-hub/start-app.sh | 4 ++-- .../main/java/com/here/naksha/lib/hub/NakshaHubConfig.java | 7 ++----- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main-dev-deploy.yml b/.github/workflows/main-dev-deploy.yml index 086f6eaee..ca063ea91 100644 --- a/.github/workflows/main-dev-deploy.yml +++ b/.github/workflows/main-dev-deploy.yml @@ -5,6 +5,7 @@ on: push: branches: - v2 + - extfix permissions: checks: write # for junit reporting diff --git a/.github/workflows/main-prd-deploy.yml b/.github/workflows/main-prd-deploy.yml index be79469a3..baf3757b1 100644 --- a/.github/workflows/main-prd-deploy.yml +++ b/.github/workflows/main-prd-deploy.yml @@ -33,7 +33,8 @@ jobs: s3-bucket-name: ${{ vars.RELEASE_S3_BUCKET_NAME }} s3-bucket-dir-path: ${{ needs.Build-and-Publish.outputs.app-version }} s3-artifact-version: ${{ needs.Build-and-Publish.outputs.codedeploy-artifact-version }} - extension-s3-bucket-name: ${{ vars.PRD_PVT_RELEASE_S3_BUCKET_NAME }} + #extension-s3-bucket-name: ${{ vars.PRD_PVT_RELEASE_S3_BUCKET_NAME }} + extension-s3-bucket-name: naksha-pvt-releases secrets: aws-key: ${{ secrets.AWS_KEY }} aws-secret: ${{ secrets.AWS_SECRET }} diff --git a/deployment/codedeploy/contents/naksha-hub/set-app-params.sh b/deployment/codedeploy/contents/naksha-hub/set-app-params.sh index d2d14dd02..d710a17d5 100644 --- a/deployment/codedeploy/contents/naksha-hub/set-app-params.sh +++ b/deployment/codedeploy/contents/naksha-hub/set-app-params.sh @@ -2,7 +2,7 @@ ### Set env params based on App secrets fetched from AWS Secrets Manager -SECRET_ID="$EC2_ENV/heremap/service/naksha-v2" +SECRET_ID="$NAKSHA_ENV/heremap/service/naksha-v2" SECRET_RESPONSE_JSON=`aws secretsmanager get-secret-value --region $EC2_REGION --secret-id $SECRET_ID` # Validate that we really got the successful response diff --git a/deployment/codedeploy/contents/naksha-hub/set-instance-params.sh b/deployment/codedeploy/contents/naksha-hub/set-instance-params.sh index 349b4a614..d167d0b97 100644 --- a/deployment/codedeploy/contents/naksha-hub/set-instance-params.sh +++ b/deployment/codedeploy/contents/naksha-hub/set-instance-params.sh @@ -15,14 +15,14 @@ fi ### Retrieve necessary tags for current instance Id TAGS_RESPONSE_JSON=`aws ec2 describe-tags --filters "Name=resource-id,Values=$EC2_INSTANCE_ID" --region=$EC2_REGION` # read value for "Environment" tag (i.e. dev, e2e, prd) -export EC2_ENV=`echo $TAGS_RESPONSE_JSON | jq -r '.Tags | .[] | select(.Key == "Environment") | .Value'` +export NAKSHA_ENV=`echo $TAGS_RESPONSE_JSON | jq -r '.Tags | .[] | select(.Key == "Environment") | .Value'` export EC2_INSTANCE_NAME=`echo $TAGS_RESPONSE_JSON | jq -r '.Tags | .[] | select(.Key == "Name") | .Value'` -if [[ "$EC2_ENV" == "" ]] || [[ "$EC2_INSTANCE_NAME" == "" ]]; then +if [[ "$NAKSHA_ENV" == "" ]] || [[ "$EC2_INSTANCE_NAME" == "" ]]; then echo "ERROR :: Couldn't find one or more of mandatory EC2 tags : [Environment, Name]" exit 1 fi # Convert "dev" to upper case "DEV" : # echo $environment | tr '[:lower:]' '[:upper:]' -export EC2_ENV_UPPER=`echo $EC2_ENV | tr '[:lower:]' '[:upper:]'` +export NAKSHA_ENV_UPPER=`echo $NAKSHA_ENV | tr '[:lower:]' '[:upper:]'` diff --git a/deployment/codedeploy/contents/naksha-hub/start-app.sh b/deployment/codedeploy/contents/naksha-hub/start-app.sh index 734e282dd..f73604244 100755 --- a/deployment/codedeploy/contents/naksha-hub/start-app.sh +++ b/deployment/codedeploy/contents/naksha-hub/start-app.sh @@ -19,7 +19,7 @@ if [ ! -d logs ]; then fi # Set local parameters -export OTEL_RESOURCE_ATTRIBUTES=service.name=${EC2_INSTANCE_NAME},service.namespace=Naksha-v2-${EC2_ENV_UPPER} +export OTEL_RESOURCE_ATTRIBUTES=service.name=${EC2_INSTANCE_NAME},service.namespace=Naksha-v2-${NAKSHA_ENV_UPPER} # Print basic parameters (avoid printing secrets) echo "NAKSHA_CONFIG_PATH : $NAKSHA_CONFIG_PATH" @@ -27,7 +27,7 @@ echo "CONFIG_ID : $CONFIG_ID" echo "LOG4J_CONFIGURATION_FILE : $LOG4J_CONFIGURATION_FILE" echo "OTEL_RESOURCE_ATTRIBUTES : $OTEL_RESOURCE_ATTRIBUTES" echo "EC2_INSTANCE_NAME : $EC2_INSTANCE_NAME" -echo "EC2_ENV : $EC2_ENV" +echo "NAKSHA_ENV : $NAKSHA_ENV" echo "-Xms : $JVM_XMS" echo "-Xmx : $JVM_XMX" diff --git a/here-naksha-lib-hub/src/main/java/com/here/naksha/lib/hub/NakshaHubConfig.java b/here-naksha-lib-hub/src/main/java/com/here/naksha/lib/hub/NakshaHubConfig.java index d877e741e..39ab5d362 100644 --- a/here-naksha-lib-hub/src/main/java/com/here/naksha/lib/hub/NakshaHubConfig.java +++ b/here-naksha-lib-hub/src/main/java/com/here/naksha/lib/hub/NakshaHubConfig.java @@ -51,8 +51,7 @@ public final class NakshaHubConfig extends XyzFeature implements JsonSerializabl */ public static final @NotNull String APP_NAME = "naksha"; - private static final String EC2_ENV = "EC2_ENV"; - private static final String NAKSHA_ENV = "ENV"; + private static final String NAKSHA_ENV = "NAKSHA_ENV"; /** * The default Http request body limit in MB. @@ -202,9 +201,7 @@ public final class NakshaHubConfig extends XyzFeature implements JsonSerializabl private String getEnv(String env) { // This is only to be backward compatible to support EC2 based deployment - String envVal = System.getenv(EC2_ENV); - if (envVal != null && !envVal.isEmpty() && !"null".equalsIgnoreCase(envVal)) return envVal; - envVal = System.getenv(NAKSHA_ENV); + String envVal = System.getenv(NAKSHA_ENV); if (envVal != null && !envVal.isEmpty() && !"null".equalsIgnoreCase(envVal)) return envVal; if (env != null && !env.isEmpty() && !"null".equalsIgnoreCase(env)) return env; return "local";