Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable crossregionaccess for s3 #272

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main-prd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ 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: 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 @@ -3,13 +3,10 @@ openapi: "3.0.2"
servers:
- url: "http://localhost:8080/"
description: "Local"
#- url: "https://naksha.ext.mapcreator.here.com/"
# description: "PRD"
#- url: "https://naksha-e2e.ext.mapcreator.here.com/"
# description: "E2E"
- url: "https://naksha-v2-dev.ext.mapcreator.here.com/"
description: "DEV"

- url: "https://naksha-v2.ext.mapcreator.here.com/"
description: "PRD"
info:
title: "Naskha Hub-API"
description: "Naksha Hub-API is a REST API to provide simple access to geo data."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public S3Client getS3Client() {
if (s3Client == null) {
synchronized (AmazonS3Helper.class) {
if (s3Client == null) {
s3Client = S3Client.builder().build();
s3Client = S3Client.builder().crossRegionAccessEnabled(true).build();
}
}
}
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 @@ -157,9 +156,7 @@ public final class NakshaHubConfig extends XyzFeature implements JsonSerializabl
}
assert __endpoint != null;
}
if (env == null) {
env = getEnv();
}
env = getEnv(env);

this.hubClassName = (hubClassName != null && !hubClassName.isEmpty()) ? hubClassName : defaultHubClassName();
this.appId = appId != null && appId.length() > 0 ? appId : "naksha";
Expand Down Expand Up @@ -202,12 +199,11 @@ public final class NakshaHubConfig extends XyzFeature implements JsonSerializabl
: defaultMaxPctParallelRequestsPerActor();
}

private String getEnv() {
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
Loading