This pattern represents an example implementation of an AWS Nitro Enclave processing messages from an Amazon SQS queue.
Deploying the solution with the AWS CDK The AWS CDK is an open-source framework for defining and provisioning cloud application resources. It uses common programming languages such as JavaScript, C#, and Python. The AWS CDK command line interface (CLI) allows you to interact with CDK applications. It provides features like synthesizing AWS CloudFormation templates, confirming the security changes, and deploying applications.
This section shows how to prepare the environment for running CDK and the sample code. For this walkthrough, you must have the following prerequisites:
- An AWS account.
- An IAM user with administrator access
- Configured AWS credentials
- Installed Node.js, Python 3, and pip. To install the example application:
When working with Python, it’s good practice to use venv to
create project-specific virtual environments. The use of venv
also reflects AWS CDK standard behavior. You can find
out more in the
workshop Activating the virtualenv.
-
Install the CDK and test the CDK CLI:
npm install -g aws-cdk && cdk --version
-
Download the code from the GitHub repo and switch in the new directory:
git clone https://github.com/aws-samples/aws-nitro-enclave-blockchain-wallet.git && cd aws-nitro-enclave-blockchain-wallet
-
Install the dependencies using the Python package manager:
pip install -r requirements.txt
-
Specify the AWS region and account for your deployment:
export CDK_DEPLOY_REGION=us-east-1 export CDK_DEPLOY_ACCOUNT=$(aws sts get-caller-identity | jq -r '.Account') export CDK_APPLICATION_TYPE=dotnet_sqs_integration export CDK_PREFIX=dev
You can set the
CDK_PREFIX
variable as per your preference. -
Trigger the
vsock-proxy
build:./scripts/build_vsock_proxy.sh
-
Build the dotnet app:
./scripts/build_dotnet_app.sh
-
Deploy the example code with the CDK CLI:
cdk deploy ${CDK_PREFIX}NitroDotnetSqsIntegration
-
Navigate to the EC2 console, copy the instance id of the EC2 instance, and connect to the instance via AWS Systems Manager (make sure you have the Session Manager plugin installed):
aws ssm start-session --target <EC2 instance id> --region ${CDK_DEPLOY_REGION}
-
Switch to ec2-user:
sudo su ec2-user
-
Attach to the signing_server enclave (ensure that the enclave has been deployed with --debug-mode flag). You should see the logs showing the source and target SQS queues.
nitro-cli console --enclave-name signing_server
-
Go to SQS on the AWS Console and send a message in the Source_Queue.
- Observe the logs on the enclave console, you will see the message being picked by the enclave.
- Switch back to SQS and poll for messages on the Target_Queue, you will see a response message coming from the enclave.
Once you have completed the deployment and tested the application, clean up the environment to avoid incurring extra cost. This command removes all resources in this stack provisioned by the CDK:
cdk destroy
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.