https://github.com/unfor19/aws-sdk-cpp-examples
An example of how to a build C++ application that uses AWS's SDK.
https://github.com/unfor19/aws-sdk-cpp-examples
aws build cmake cpp docker make sdk
Last synced: 3 months ago
JSON representation
An example of how to a build C++ application that uses AWS's SDK.
- Host: GitHub
- URL: https://github.com/unfor19/aws-sdk-cpp-examples
- Owner: unfor19
- License: mit
- Created: 2021-03-11T22:28:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-13T08:41:22.000Z (almost 3 years ago)
- Last Synced: 2026-01-30T15:51:28.224Z (5 months ago)
- Topics: aws, build, cmake, cpp, docker, make, sdk
- Language: Dockerfile
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-sdk-cpp-examples
[](https://github.com/unfor19/aws-sdk-cpp-examples/actions/workflows/docker-latest.yml) [](https://hub.docker.com/r/unfor19/aws-sdk-cpp-examples)
An example of how to a build C++ application that uses AWS's SDK.
## Requirements
- [Docker](https://docs.docker.com/get-docker/)
- AWS account with existing S3 buckets to test the [s3-demo](./src/s3-demo.cpp) application
## Usage
### Build
```bash
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine"
$ git clone https://github.com/unfor19/aws-sdk-cpp-examples.git
$ cd aws-sdk-cpp-examples
$ docker build -t "$DOCKER_IMAGE" .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" -f Dockerfile.alpine .
```
### Run
The executeable `s3-demo` is copied `/usr/local/bin` during the build time. The demo application consumes only one argument - `region`
```bash
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-alpine"
# Using environment variables
$ docker run --rm -it \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN "$DOCKER_IMAGE" s3-demo eu-west-1
# Output: List of buckets ...
# Using configuration file in readonly mode (haven't tested it)
$ docker run --rm -it -v $HOME/.aws/:/root/.aws/:ro "$DOCKER_IMAGE" s3-demo eu-west-1
# Output: List of buckets ...
```
## Development
### Build
```bash
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-dev" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-alpine-dev"
$ git clone https://github.com/unfor19/aws-sdk-cpp-examples.git
$ cd aws-sdk-cpp-examples
$ docker build -t "$DOCKER_IMAGE" --target build-app --build-arg APP_MOUNT_VOLUME="true" .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" --target build-app --build-arg APP_MOUNT_VOLUME="true" . -f Dockerfile.alpine
```
### Run
Mount this project to the container and then build the application.
```bash
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-dev" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine-dev"
# Change something in src/s3-demo.cpp with local IDE and build the application while in the container
# Using environment variables
$ docker run --rm -it -v "$PWD"/:/code/ \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN "$DOCKER_IMAGE" bash
root@852c75b69bd4:/code/build# s3-demo eu-west-1
# Output: List of buckets ...
# Change something in src/s3-demo.cpp with local IDE and build the application while in the container
root@852c75b69bd4:/code/build# make
root@852c75b69bd4:/code/build# s3-demo eu-west-1
# Output: List of buckets ...
```
### Build Only aws-sdk-cpp
```bash
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-sdk" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine-sdk"
$ docker build -t "$DOCKER_IMAGE" --target build-aws-sdk-cpp .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" --target build-aws-sdk-cpp . -f Dockerfile.alpine
```
## Authors
Created and maintained by [Meir Gabay](https://github.com/unfor19)
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/unfor19/aws-sdk-cpp-examples/blob/master/LICENSE) file for details