Skip to content

A simple POC of a Java Jetty Service using config stored in AWS Parameter Store.

License

Notifications You must be signed in to change notification settings

selatotal/aws-parameter-store-poc

Repository files navigation

aws-parameter-store-poc

A simple POC of a Java Jetty Service using config stored in AWS Parameter Store.

The main goal is to use AWS Parameter Store as a config service and a Java Webservice and don't use spring-cloud-starter-aws-parameter-store-config as dependency.

How-to setup

First of all, you need to create some parameters in AWS System Managers.

You can do it by AWS Console or AWS CLI, as described here, but I think that the best is to use a Terraform Script that I created in aws-parameter-store-poc-infra/terraform folder.

To use, you can simply execute the scripts as described below:

  • Add your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in your enviroment:
export AWS_ACCESS_KEY_ID=your-aws-access-key-here
export AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key-here
  • To Create Parameters by Terraform
scripts/deploy-infra.sh path-to-tfstate environment region

Example:

scripts/deploy-infra.sh /tmp dev us-east-1
  • To Remove Parameters by Terraform
scripts/destroy-infra.sh path-to-tfstate environment region

Example:

scripts/destroy-infra.sh /tmp dev us-east-1

How-to Build And Run

  • Add your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in your enviroment:
export AWS_ACCESS_KEY_ID=your-aws-access-key-here
export AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key-here
export AWS_DEFAULT_REGION=your-aws-region-here
  • Execute run.sh script
scripts/run.sh

Your project will listen requests at 8080 port. Now you can test access with the following HTTP requests:

Request a parameter

http://localhost:8080/parameter/poc-parameter-store/dev/parameter1

{
  "name": "/poc-parameter-store/dev/parameter1",
  "type": "String",
  "value": "parameter value 1"
}

http://localhost:8080/parameter/poc-parameter-store/dev/parameter2

{
  "name": "/poc-parameter-store/dev/parameter2",
  "type": "StringList",
  "value": "String 1, String 2, String 3"
}

Request a path's parameters list

http://localhost:8080/path/poc-parameter-store/dev

[
  {
    "name": "/poc-parameter-store/dev/parameter1",
    "type": "String",
    "value": "parameter value 1"
  },
  {
    "name": "/poc-parameter-store/dev/parameter2",
    "type": "StringList",
    "value": "String 1, String 2, String 3"
  }
]

Create a new Parameter

You can create a new Parameter using curl to do a POST method with name, type and value.

curl --location --request POST 'http://localhost:8080/parameter' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "/poc-parameter-store/dev/parameter3",
    "type": "StringList",
    "value": "parameter value 1, p2, p3"
}'

About

A simple POC of a Java Jetty Service using config stored in AWS Parameter Store.

Topics

Resources

License

Stars

Watchers

Forks