Accessing the infrastructure
The infrastructure components are provisioned on the background for each of the projects. Any container/pod that is running on the project's namespace will have access to the infrastructure components.
Our platform is language agnostic. We provide a lightweight library called emp_hooks
in python that simplifies interacting with infrastructure components but is not at all required or needed to use the platform.
The aws libraries are built to automatically pick up the available credentials from the environment.
For example, the following snippet will access the DynamoDB table and write and read from it.
import boto3
import os
def main():
region_name = os.getenv('AWS_REGION')
table_name = os.getenv('AWS_DYNAMODB_TABLE_NAME')
dynamodb = boto3.resource("dynamodb", region_name=region_name)
table = dynamodb.Table(table_name)
test_item = {
"id": "test-id-1",
"Data": "Hello from the project!"
}
table.put_item(Item=test_item)
print(f"Successfully wrote item to {table_name}: {test_item}")
response = table.get_item(Key={"id": "test-id-1"})
item = response.get("Item")
if item:
print(f"Successfully read item from {table_name}: {item}")
else:
print(f"No item found in {table_name}")
if __name__ == "__main__":
main()
The following infrastructure-related environment variables are automatically injected into each pod:
DynamoDB Related:
AWS_DYNAMODB_TABLE_ARN
- The ARN of the DynamoDB tableAWS_DYNAMODB_TABLE_NAME
- The name of the DynamoDB table
ECR Related:
AWS_ECR_REPO_URI
- The URI of the ECR repository
S3 Related:
AWS_S3_BUCKET_ARN
- The ARN of the S3 bucketAWS_S3_BUCKET_NAME
- The name of the S3 bucket
Secrets Related:
AWS_SECRET_ARN
- The ARN of the AWS SecretAWS_SECRET_NAME
- The name of the AWS Secret
SQS Related:
AWS_SQS_QUEUE_ARN
- The ARN of the SQS queueAWS_SQS_QUEUE_NAME
- The name of the SQS queue
Region Configuration:
AWS_REGION
- The AWS region (default: us-east-2)AWS_DEFAULT_REGION
- The AWS default region (default: us-east-2)
Persistent Volume (EFS) Related:
FILESYSTEM_PATH
- The path to the EFS file systemDEPLOYMENT_FILESYSTEM_PATH
- The path for the deployment to use the EFS file system
Environment:
ENVIRONMENT
- The deployment environment (e.g., production)
Last updated