This project provides an HTTP server using Go, which interacts with AWS Services. This project is useful for running a sidecar, to use original images without a hassle.
- Fetch decrypted parameters from AWS SSM.
- Fetch and serve files from AWS S3.
- Upload files to AWS S3.
- Fetch ECR authorization token.
- Fetch caller identity from AWS STS.
- Basic CI/CD pipeline using GitHub Actions for automatic builds and tests.
- Go 1.17 or later
- AWS CLI configured with necessary permissions
- Git installed
Get the Container Image
docker pull ghcr.io/leneffets/awsserver:v1.0.0
docker pull ghcr.io/leneffets/awsserver:latest
-
Clone the repository:
git clone [email protected]:USERNAME/REPO_NAME.git cd REPO_NAME
-
Initialize the Go module:
go mod tidy
-
Configure AWS credentials:
Ensure you have AWS credentials configured, typically in
~/.aws/credentials
.
To start the HTTP server locally on port 3000, run the following command:
# Port may be changed via Environment, default 3000
export PORT=3000
go run cmd/server/main.go
Fetch a decrypted parameter from AWS SSM.
-
URL:
/ssm
-
Method:
GET
-
Query Parameters:
name
: Name of the SSM parameter to fetch.
-
Example:
curl "http://localhost:3000/ssm?name=example_parameter"
Put a parameter to AWS SSM.
-
URL:
/ssm
-
Method:
POST
-
Query Parameters:
name
: Name of the SSM parameter to put.value
: Value of the SSM parameter to put.type
: Type of the SSM parameter to put. (String, SecureString)
-
Example:
curl -X POST -d "name=/path/to/parameter&value=somevalue&type=String" http://localhost:3000/ssm
Fetch a file from an S3 bucket.
-
URL:
/s3
-
Method:
GET
-
Query Parameters:
bucket
: Name of the S3 bucket.key
: Key of the file in the S3 bucket.
-
Example:
curl "http://localhost:3000/s3?bucket=example-bucket&key=example-key"
Upload a file to an S3 bucket.
-
URL:
/s3
-
Method:
POST
-
Query Parameters:
bucket
: Name of the S3 bucket.key
: Key of the file in the S3 bucket.
-
Example:
curl -X POST -F 'file=@/path/to/your/file' "http://localhost:3000/s3?bucket=example-bucket&key=example-key"
Fetch an authorization token for ECR.
-
URL:
/ecr/login
-
Method:
GET
-
Example:
curl "http://localhost:3000/ecr/login" | docker login --username AWS --password-stdin aws-account-id.dkr.ecr.eu-central-1.amazonaws.com
Fetch the caller identity from AWS STS.
-
URL:
/sts
-
Method:
GET
-
Example:
curl "http://localhost:3000/sts"
To run the tests:
go test -v ./...
This project uses GitHub Actions for continuous integration. The pipeline is defined in .github/workflows/ci.yml
and performs the following actions on each push or pull request to the main
branch:
- Checks out the code.
- Sets up the Go environment.
- Installs dependencies.
- Builds the project.
- Runs tests.
-
Review pipeline runs:
Go to the
Actions
tab in your GitHub repository to view the status of the workflow runs.
Feel free to fork this repository and create pull requests. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.