Skip to content

Commit

Permalink
Remove EC2_ENV variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajeev Jain committed May 24, 2024
1 parent addfc1d commit bbc2361
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main-dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- v2
- extfix

permissions:
checks: write # for junit reporting
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/main-prd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:]'`
4 changes: 2 additions & 2 deletions deployment/codedeploy/contents/naksha-hub/start-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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"
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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit bbc2361

Please sign in to comment.