diff --git a/README.md b/README.md index c93616713d8533c8ada9ff8ad3572a3999733ed0..40700bd1d24c1de09cb6a4fa8e0d88f1a86194a9 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,8 @@ server.servlet.contextPath=/ server.port=8080 ``` # new update + + +## AWS + +Instructions for running and testing this service can be found [here](./provider/notification-aws/README.md) \ No newline at end of file diff --git a/devops/azure/chart/templates/auth.yaml b/devops/azure/chart/templates/auth.yaml index 81b9c11de6829209be551126f0361db503eec31a..e09366c401831c556c2da130a0b967192a6c16d6 100644 --- a/devops/azure/chart/templates/auth.yaml +++ b/devops/azure/chart/templates/auth.yaml @@ -30,4 +30,4 @@ spec: to: - operation: notPaths: ["/","*/swagger-resources","*/swagger", - "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/actuator/health"] \ No newline at end of file + "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/swagger-ui/index.html","*/actuator/health"] diff --git a/devops/azure/chart/templates/authSB.yaml b/devops/azure/chart/templates/authSB.yaml index 50e54fb1281dc4c6759c1d4327b16325ffbcb258..012db0dc6014f5b9ff1e074b602fcec83565b807 100644 --- a/devops/azure/chart/templates/authSB.yaml +++ b/devops/azure/chart/templates/authSB.yaml @@ -30,4 +30,4 @@ spec: to: - operation: notPaths: ["/","*/swagger-resources","*/swagger", - "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/actuator/health"] \ No newline at end of file + "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/swagger-ui/index.html","*/actuator/health"] diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index a6f9651b77df6cc74a70074ced49168103aaca52..c3cb168ae3a700618f455e26579d77a1bfb3ff12 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -47,7 +47,7 @@ spec: - containerPort: 80 readinessProbe: httpGet: - path: /api/notification/v1/swagger-ui.html + path: /api/notification/v1/swagger-ui/index.html port: 80 volumeMounts: - name: azure-keyvault @@ -106,4 +106,4 @@ spec: - name: event_grid_to_service_bus_enabled value: "false" - name: event_grid_enabled - value: "true" \ No newline at end of file + value: "true" diff --git a/devops/azure/chart/templates/deploymentSB.yaml b/devops/azure/chart/templates/deploymentSB.yaml index e254ef27454ef8ef09ddec45304a26da3ba0e46f..49b24272e615b18abd5645b8d3af79a5587f0633 100644 --- a/devops/azure/chart/templates/deploymentSB.yaml +++ b/devops/azure/chart/templates/deploymentSB.yaml @@ -43,7 +43,7 @@ spec: - containerPort: 81 readinessProbe: httpGet: - path: /api/notification/v1/swagger-ui.html + path: /api/notification/v1/swagger-ui/index.html port: 81 volumeMounts: - name: azure-keyvault @@ -102,4 +102,4 @@ spec: - name: event_grid_to_service_bus_enabled value: "false" - name: event_grid_enabled - value: "false" \ No newline at end of file + value: "false" diff --git a/provider/notification-aws/README.md b/provider/notification-aws/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d639f8879d691c996b3a5ea288cc3b65ee1ac295 --- /dev/null +++ b/provider/notification-aws/README.md @@ -0,0 +1,154 @@ +# Notification Service +The Notification service allows for interested consumers to subscribe to data and +metadata changes using a publish/subscriber pattern. +notification-aws is a [Spring Boot](https://spring.io/projects/spring-boot) service has a /push-handlers//records-changed API to notify subscribers of any updates. + +## Running Locally + +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. + +### Prerequisites +Pre-requisites + +* JDK 8 (https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html) +* Maven 3.8.3 or later +* Lombok 1.16 or later +* OSDU Instance deployed on AWS + +### Service Configuration +In order to run the service locally or remotely, you will need to have the following environment variables defined. + +| name | example value | required | description | sensitive? | +| --- | --- | --- | --- | --- | +| `APPLICATION_PORT` | `8080` | yes | The port the service will be hosted on. | no | +| `AWS_REGION` | `us-east-1` | yes | The region where resources needed by the service are deployed | no | +| `AWS_ACCESS_KEY_ID` | `ASIAXXXXXXXXXXXXXX` | yes | The AWS Access Key for a user with access to Backend Resources required by the service | yes | +| `AWS_SECRET_ACCESS_KEY` | `super-secret-key==` | yes | The AWS Secret Key for a user with access to Backend Resources required by the service | yes | +| `AWS_SESSION_TOKEN` | `session-token-xxxxxxxxxx` | no | AWS Session token needed if using an SSO user session to authenticate | yes | +| `RESOURCE_PREFIX` | `osdu-prefix` | yes | The Resource Prefix defined during deployment | no | +| `LOG_LEVEL` | `DEBUG` | yes | The Log Level severity to use (https://www.tutorialspoint.com/log4j/log4j_logging_levels.htm) | no | +| `SSM_ENABLED` | `true` | yes | Set to 'true' to use SSM to resolve config properties, otherwise use env vars | no | +| `SSL_ENABLED` | `false` | no | Set to 'false' to disable SSL for local development | no | +| `ENTITLEMENTS_BASE_URL` | `http://localhost:8081` or `https://some-hosted-url` | yes | Specify the base url for an entitlements service instance. Can be run locally or remote | no | +| `REGISTER_BASE_URL` | `http://localhost:8081` or `https://some-hosted-url` | yes | Specify the base url for Register service instance. | no | + + +### Run Locally +Check that maven is installed: + +example: +```bash +$ mvn --version +Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739) +Maven home: /usr/local/Cellar/maven/3.8.3/libexec +Java version: 1.8.0_312, vendor: Amazon.com Inc., runtime: /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/jre +... +``` + +You may need to configure access to the remote maven repository that holds the OSDU dependencies. Copy one of the below files' content to your .m2 folder +* For development against the OSDU GitLab environment, leverage: `<REPO_ROOT>~/.mvn/community-maven.settings.xml` +* For development in an AWS Environment, leverage: `<REPO_ROOT>/provider/notification-aws/maven/settings.xml` + +* Navigate to the service's root folder and run: + +```bash +mvn clean package -pl notification-core,provider/notification-aws +``` + +* If you wish to build the project without running tests + +```bash +mvn clean package -pl notification-core,provider/notification-aws -DskipTests +``` + +After configuring your environment as specified above, you can follow these steps to run the application. These steps should be invoked from the *repository root.* +<br/> +<br/> +NOTE: If not on osx/linux: Replace `*` with version numbers as defined in the provider/notification-aws/pom.xml file + +```bash +java -jar provider/notification-aws/target/notification-aws-*.*.*-SNAPSHOT-spring-boot.jar +``` + +## Testing + + ### Running Integration Tests + This section describes how to run OSDU Integration tests (testing/notification-test-aws). + + You will need to have the following environment variables defined. + + | name | example value | description | sensitive? + | --- | --- | --- | --- | + | `AWS_ACCESS_KEY_ID` | `ASIAXXXXXXXXXXXXXX` | The AWS Access Key for a user with access to Backend Resources required by the service | yes | + | `AWS_SECRET_ACCESS_KEY` | `super-secret-key==` | The AWS Secret Key for a user with access to Backend Resources required by the service | yes | + | `AWS_SESSION_TOKEN` | `session-token-xxxxxxxxx` | AWS Session token needed if using an SSO user session to authenticate | yes | + | `AWS_COGNITO_USER_POOL_ID` | `us-east-1_xxxxxxxx` | User Pool Id for the reference cognito | no | + | `AWS_COGNITO_CLIENT_ID` | `xxxxxxxxxxxx` | Client ID for the Auth Flow integrated with the Cognito User Pool | no | + | `AWS_COGNITO_AUTH_FLOW` | `USER_PASSWORD_AUTH` | Auth flow used by reference cognito deployment | no | + | `AWS_COGNITO_AUTH_PARAMS_USER` | `int-test-user@testing.com` | Int Test Username | no | + | `AWS_COGNITO_AUTH_PARAMS_USER_NO_ACCESS` | `no-access-user@testing.com` | Int Test No Access Username | no | + | `AWS_COGNITO_AUTH_PARAMS_PASSWORD` | `some-secure-password` | Int Test User/NoAccessUser Password | yes | + | `ENVIRONMENT` | `DEV` or `LOCAL` | set to DEV for deployed service testing or local for local testing | no | + | `HMAC_SECRET` | `02030**********` | sensitive secret to run HMAC tests | yes | + | `REGISTER_CUSTOM_PUSH_PATH` | `api/register/v1/awstest/aws/challenge` | Custom Push Path for subscription testing | no | + | `REGISTER_CUSTOM_PUSH_URL_HMAC` |value of `$NOTIFICATION_REGISTER_BASE_URL$REGISTER_CUSTOM_PUSH_PATH` | Custom Push Path for subscription testing | no | + | `NOTIFICATION_REGISTER_BASE_URL` | `http://localhost:8081/api/register/v1` | Register service url | no | - | + | `NOTIFICATION_BASE_URL` | `http://localhost:8080/api/notification/v1/` | Notification service url | no | + + + + **Creating a new user to use for integration tests** + ``` + aws cognito-idp admin-create-user --user-pool-id ${AWS_COGNITO_USER_POOL_ID} --username ${AWS_COGNITO_AUTH_PARAMS_USER} --user-attributes Name=email,Value=${AWS_COGNITO_AUTH_PARAMS_USER} Name=email_verified,Value=True --message-action SUPPRESS + + aws cognito-idp initiate-auth --auth-flow ${AWS_COGNITO_AUTH_FLOW} --client-id ${AWS_COGNITO_CLIENT_ID} --auth-parameters USERNAME=${AWS_COGNITO_AUTH_PARAMS_USER},PASSWORD=${AWS_COGNITO_AUTH_PARAMS_PASSWORD} + ``` + + **Entitlements group configuration for integration accounts** + <br/> + In order to add user entitlements, run entitlements bootstrap scripts in the entitlements project + + | AWS_COGNITO_AUTH_PARAMS_USER | AWS_COGNITO_AUTH_PARAMS_USER_NO_ACCESS | + | --- | --- | + | service.entitlements.user | service.entitlements.user | + | users.datalake.ops | + | notification.pubsub | + + + Execute following command to build code and run all the integration tests: + +### Run Tests simulating Pipeline + +* Prior to running tests, scripts must be executed locally to generate pipeline env vars + +```bash +testing/notification-test-aws/build-aws/prepare-dist.sh + +#Set Neccessary ENV Vars here as defined in run-tests.sh + +dist/testing/integration/build-aws/run-tests.sh +``` + +### Run Tests using mvn +Set required env vars and execute the following: +``` +mvn clean package -f testing/pom.xml -pl notification-test-core,notification-test-aws -DskipTests +mvn test -f testing/notification-test-aws/pom.xml +``` + + + +## License +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/provider/notification-aws/pom.xml b/provider/notification-aws/pom.xml index 25ff10efb6e426ddcf5a9a49eceb7644b7ac0234..033d66ba8ca047b3fb1eb1c753b456901a5554c7 100644 --- a/provider/notification-aws/pom.xml +++ b/provider/notification-aws/pom.xml @@ -36,8 +36,36 @@ <maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.source>${java.version}</maven.compiler.source> <aws.version>1.11.1018</aws.version> + <log4j2.version>2.17.1</log4j2.version> + <os-core-common.version>0.13.0-rc3</os-core-common.version> </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.opengroup.osdu</groupId> + <artifactId>os-core-common</artifactId> + <version>${os-core-common.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-to-slf4j</artifactId> + <version>${log4j2.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4j2.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> <dependency> <groupId>org.opengroup.osdu.core.aws</groupId>