This project is a collection of independent .NET projects written in C# .NET 5 that demonstrate how to integrate with various AWS services using the AWS SDK for dotnet.
- Toolchain
- AWS Services
- Projects
- AWS CLI
- AWS Project Configuration
- Signup With AWS Free Tier
- Learning
- Certification
All projects have been built or tested on Windows 10 and Ubuntu 20.04. The following list is a summary of the primary tools, languages and frameworks used to build the application:
- Visual Studio Code - Visual Studio Code is a source-code editor developed by Microsoft for Windows, Linux and macOS.
- Ubuntu 20.04 - Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.
- .NET5 - .NET5 is a free and open-source managed software framework for Linux, Windows and macOS.
- C# - A multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.
So far, projects have been created for the following AWS Services:
-
Amazon S3 - An AWS service that provides authentication, authorization, and user management for your web and mobile apps.
-
S3 ConsoleApp - Console Application
-
-
Amazon SNS - Amazon Simple Notification Service (Amazon SNS) is a web service that coordinates and manages the delivery or sending of messages to subscribing endpoints or clients.
-
SNS ConsoleApp - Console Application
-
-
Amazon SQS - Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.
-
SQS ConsoleApp - Console Application
-
-
Amazon Cognito - Amazon Simple Notification Service (Amazon SNS) is a web service that coordinates and manages the delivery or sending of messages to subscribing endpoints or clients.
-
Cognito Mvc - ASP.NET Core MVC Application
-
Cognito Api - ASP.NET Core WebAPI Application
-
-
Amazon DynamoDb - Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.
-
DynamoDb ConsoleApp - Console Application
-
-
Cognito Mvc - This project demonstrates how to integrate an ASP.NET Core MVC web application with Amazon Cognito using the Amazon SDK.
The following features have been implemented:
- Signup for a new account
- Confirm Signup (using confirmation code)
- Sign into account
- Sign out of account
-
Cognito Api - This project demonstrates how to integrate a .NET Core Web Api application with Amazon Cognito using the Amazon SDK.
This Web Api application provides the following endpoints:
- Signups
- POST api/signups - Allows an api consumer to signup for a new account
- Tokens
- POST api/tokens - Provides JWT access token for valid account credentials
- Values
- GET api/values - An unauthorized endpoint that returns a list of values
- GET api/values/123 - An authorized endpoint (Requires JWT access token) that returns a single value
- Signups
-
S3 ConsoleApp - This project demonstrates how to integrate a .NET Core Console application with Amazon S3 using the Amazon SDK.
The following features have been implemented:
- List all S3 buckets
- Create new S3 bucket
- Delete S3 bucket
-
DynamoDb ConsoleApp - This project demonstrates how to integrate a .NET Core console application with DynamoDb using the Amazon SDK. This application provides the functionality required to both manage DynamoDb tables, and manage the data stored in a DynamoDB table
The following features have been implemented:
- Manage Tables
- Create table
- List and find tables
- Wait for tables to be described (eventually consistent)
- Delete table
- Manage Book Table Data
- Automatically creates Book table
- Add books to Book table
- Update books in Book table
- Delete books from Book table
- List and find books in Book table
- Manage Tables
-
SNS ConsoleApp - This project demonstrates how to integrate a .NET Core console application with SNS using the Amazon SDK. This application provides the functionality required to manage SNS topcs, subscriptions, and publications.
The following features have been implemented:
- Manage Topics
- Create topic
- List and find topics
- Delete topic
- Manage Subscriptions
- Create an email subscription
- Cancel a subscription
- List subscriptions
- Manage Publications
- An example showing how to publish a 'Game Ranking' to a 'game-ranking' topic
- Manage Topics
-
SQS ConsoleApp - This project demonstrates how to integrate a .NET Core console application with SQS using the Amazon SDK.
The following features have been implemented:
- Manage Queues
- Create queue
- List queues
- Delete queue
- Get queue url
- Manage Game Ranking Queue
- Enqueue game ranking to queue
- Dequeue game rankings from queue
- Manage Queues
Even as a C#.NET developer, you will come to find the AWS CLI to be one of your most valuable tools. See the official AWS CLI documentation to learn more.
Please install Version 2 of the AWS CLI.
For installation instructions for all the major platforms, please visit the official AWS CLI installation documentation
From your terminal window, type the following commands:
# list aws cli configuration data
aws configure list
# list aws cli configuration profiles (only available from version 2)
aws configure list-profiles
Type the following command to create a default profile:
aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
AWS configuration can be found in your home folder at the following locations:
# windows
~\aws\credentials
~\aws\config
# linux / macOS
~/aws/credentials
~/aws/config
Type the following command to create additional profiles:
aws configure --profile s3demo
aws configure --profile sqsdemo
aws configure --profile dynamodbdemo
We need to provide some AWS configuration before we can start using the AWS SDK in our projects. In this section, I provide 3 options that one can use to provide the configuration that the AWS SDK requires at runtime.
- provide configuration in appsettings.json file
- provide configuration using environment variables
- provide configuration using dotnet user secrets
It is also considered bad practice to store any AWS configuration in the application configuration files. Therefore, the 2 preferred approaches to storing your AWS configuration are as follows:
- provide configuration using environment variables
- provide configuration using dotnet user secrets
IMPORTANT
NEVER store any AWS credentials (access_key_id, secret__access__key_id) in configuration files
This approach is not considered the best approach as it uses an application configuration file that can be committed to source control with sensitive credentials.
Add the following configuration section to your appsettings.json
file:
// appsettings.json
{
"AWS": {
"Region": "us-east-1",
"Profile": "aws-demo"
}
}
From your terminal, add the following environment variables:
- AWS_PROFILE
- AWS_REGION
# Powershell
$env:AWS_PROFILE = "aws-demo"
$env:AWS_REGION = "us-east-1"
# Linux / macOS
AWS_PROFILE='aws-demo'
AWS_REGION='us-east-1'
# Windows CMD
set AWS_PROFILE=aws-demo
set AWS_REGION=us-east-1
NOTE
This is the approach being used for all projects in this project
Working with user secrets involves using the Secret Manager tool. According to the official Microsoft documentation:
The Secret Manager tool stores sensitive data during the development of an ASP.NET Core project. In this context, a piece of sensitive data is an app secret. App secrets are stored in a separate location from the project tree. The app secrets are associated with a specific project or shared across several projects. The app secrets aren't checked into source control
For more information, see the official documentation
WARNING
The Secret Manager tool doesn't encrypt the stored secrets and shouldn't be treated as a trusted store. It's for development purposes only. The keys and values are stored in a JSON configuration file in the user profile directory.
From the terminal, type the following command to initialize user-secrets,
cd ./Aws.S3Demo.ConsoleApp
dotnet user-secrets init
The following entry is added to the project file:
<PropertyGroup>
<UserSecretsId>567f0dg2-06b1-5567-94a5-8c855a1a7972</UserSecretsId>
</PropertyGroup>
Use the following commands to access the user secrets location and secrets.json file:
# Powershell
cat $env:APPDATA\Microsoft\UserSecrets\<USER_SECRETS_ID>\secrets.json
type $env:APPDATA\Microsoft\UserSecrets\<USER_SECRETS_ID>\secrets.json
# Linux / macOS
cat ~/.microsoft/usersecrets/<USER_SECRETS_ID>/secrets.json
# Windows CMD
type %APPDATA%\Microsoft\UserSecrets\<USER_SECRETS_ID>\secrets.json
NOTE
Substitute <USER_SECRETS_ID> with the GUID found in the project file.
<UserSecretsId>567f0dg2-06b1-5567-94a5-8c855a1a7972</UserSecretsId>
We need to add 2 user secrets representing the 2 values required by the AWS SDK:
- Profile
- Region
In the section Using appsettings, we had the following configuration:
{
"AWS": {
"Region": "us-east-1",
"Profile": "aws-demo"
}
}
We now need to add 2 user secrets that align with the aforementioned AWS configuration:
dotnet user-secrets set "AWS:Profile" "aws-demo"
dotnet user-secrets set "AWS:Region" "us-east-1"
dotnet user-secrets list
To individually remove user secrets, use the following commands:
dotnet user-secrets remove "AWS:Profile"
dotnet user-secrets remove "AWS:Region"
Alternatively, you can clear all user secrets using the following command:
dotnet user-secrets clear
WARNING
You need a valid credit card to signup for the AWS Free Tier
AWS offers a generous free tier with a relatively straight forward signup process. Unfortunately, you will need a credit card to complete the signup process. Go to Signup.
NOTE
Check out this official getting started video (5 mins) that takes you through the signup process
For more information about the AWS Free Tier, see the following links:
AWS is vast and there are many great resources to learn about AWS. The following list is a curated list of learning resources that can be used to learn and remain current with AWS technology.
- AWS Learning Library
- AWS Cloud Practitioner Essentials
- AWS Whitepapers and Guides
- AWS Blogs
- AWS Podcasts
- AWS Twitter
- AWS Twitch
- Exam Readiness: AWS Certified Developer Associate
- Exam Readiness: AWS Certified Architect Associate
- Exam Readiness: AWS Certified Sysops Associate
- AWS Certified Cloud Practitioner
- AWS Certified Developer Associate
- AWS Certified Solutions Architect Associate
- AWS Certified Sysops Administrator Associate
- AWS Cloud Training
- AWS Certified Cloud Practitioner
- AWS Certified Developer Associate
- AWS Certified Architect Associate
- AWS Certified Sysops Administrator Associate
- Whizlabs AWS Cloud Training
- AWS Certified Cloud Practitioner
- AWS Certified Developer Associate
- AWS Certified Architect Associate
- AWS Certified Sysops Administrator Associate
I use SemVer for versioning. For the versions available, see the tags on this repository.
- Douglas Minnaar - Initial work - drminnaar