A comprehensive command-line interface for creating various AWS resources including S3 buckets, EC2 instances, DynamoDB tables, RDS instances, Lambda functions, and SNS topics.
This CLI tool provides two complementary interfaces for AWS resource management:
- S3 Bucket Management: Create S3 buckets with region specification
- EC2 Instance Management: Launch EC2 instances with customizable configuration
- Package Installation: Install as
pip install -e .
and useaws-resources
command - Advanced Error Handling: Comprehensive AWS error handling and user-friendly messages
- Hierarchical Commands: Professional CLI experience with argparse subcommands
- DynamoDB Tables: Create DynamoDB tables with partition keys and optional sort keys
- RDS Instances: Create RDS database instances with various engines
- Lambda Functions: Create Lambda functions with different runtimes
- SNS Topics: Create SNS topics for messaging
- Direct Python Execution: Use
python aws_cli.py
for broader service access
- Python 3.8 or higher
- AWS credentials configured (via AWS CLI, environment variables, or IAM roles)
- Required Python packages (see requirements.txt)
- Clone this repository:
git clone https://github.com/nataliagranato/aws-resources.git
cd aws-resources
- Install dependencies:
pip install -r requirements.txt
- Install the package for modern CLI experience:
pip install -e .
- Configure AWS credentials (choose one method):
- Using AWS CLI:
aws configure
- Using environment variables:
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
- Using IAM roles (if running on EC2)
- Using AWS CLI:
Create a new S3 bucket:
aws-resources s3 create-bucket --bucket-name my-unique-bucket --region us-west-2
Parameters:
--bucket-name
: Name of the S3 bucket (must be globally unique)--region
: AWS region for the bucket (e.g., us-east-1, us-west-2)
Launch new EC2 instances:
aws-resources ec2 create-instances \
--image-id ami-12345678 \
--instance-type t2.micro \
--key-name my-ec2-key \
--count 2 \
--region us-east-1
Parameters:
--image-id
: AMI ID to launch the instance from (required)--instance-type
: EC2 instance type like t2.micro, t3.small (required)--key-name
: Name of the EC2 Key Pair for SSH access (required)--count
: Number of instances to launch (default: 1)--region
: AWS region for the instances (required)
-v, --verbose
: Enable verbose output for detailed information
Get help for any command:
aws-resources --help
aws-resources s3 --help
aws-resources ec2 create-instances --help
python aws_cli.py <service> <action> [options]
Create an S3 bucket:
python aws_cli.py s3 create-bucket --name my-unique-bucket-name --region us-east-1
Create an EC2 instance:
python aws_cli.py ec2 create-instance --image-id ami-0abcdef1234567890 --instance-type t2.micro --region us-east-1
With optional parameters:
python aws_cli.py ec2 create-instance --image-id ami-0abcdef1234567890 --instance-type t2.micro --region us-east-1 --key-name my-key-pair --security-groups default
Create a simple table with partition key only:
python aws_cli.py dynamodb create-table --name my-table --partition-key id --region us-east-1
Create a table with both partition and sort keys:
python aws_cli.py dynamodb create-table --name my-table --partition-key userId --partition-key-type S --sort-key timestamp --sort-key-type N --region us-east-1
Create an RDS MySQL instance:
python aws_cli.py rds create-instance --identifier my-database --engine mysql --username admin --password mypassword123 --region us-east-1
With additional options:
python aws_cli.py rds create-instance --identifier my-database --engine postgres --instance-class db.t3.small --username admin --password mypassword123 --storage 50 --publicly-accessible --region us-east-1
Create a Lambda function (with default Hello World code):
python aws_cli.py lambda create-function --name my-function --runtime python3.9 --role arn:aws:iam::123456789012:role/lambda-execution-role --region us-east-1
With custom code and settings:
python aws_cli.py lambda create-function --name my-function --runtime python3.9 --role arn:aws:iam::123456789012:role/lambda-execution-role --handler index.handler --code-file my-function.zip --timeout 60 --memory 256 --region us-east-1
Create an SNS topic:
python aws_cli.py sns create-topic --name my-topic --region us-east-1
With display name:
python aws_cli.py sns create-topic --name my-topic --display-name "My Notification Topic" --region us-east-1
aws-resources s3 create-bucket --bucket-name my-app-logs-2024 --region us-east-1
aws-resources ec2 create-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t2.micro \
--key-name my-keypair \
--region us-west-2
aws-resources -v ec2 create-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t3.small \
--key-name production-key \
--count 3 \
--region eu-west-1
The CLI is built with extensibility in mind:
- Base Service Class: Common functionality for all AWS services
- Service-Specific Modules: Dedicated modules for each AWS service
- Argument Parsing: Hierarchical subcommands using argparse
- Error Handling: Comprehensive error handling with user-friendly messages
--region
: AWS region (required for all commands)
--name
: Bucket name (must be globally unique)
--image-id
: AMI ID to launch (required)--instance-type
: Instance type (required, e.g., t2.micro)--key-name
: EC2 Key Pair name (optional)--security-groups
: Security group names (optional, space-separated)
--name
: Table name (required)--partition-key
: Partition key attribute name (required)--partition-key-type
: Partition key type - S/N/B (default: S)--sort-key
: Sort key attribute name (optional)--sort-key-type
: Sort key type - S/N/B (default: S)
--identifier
: DB instance identifier (required)--engine
: Database engine - mysql/postgres/mariadb/oracle-ee/sqlserver-ex (required)--username
: Master username (required)--password
: Master password (required)--instance-class
: DB instance class (default: db.t3.micro)--storage
: Allocated storage in GB (default: 20)--security-groups
: VPC security group IDs (optional, space-separated)--publicly-accessible
: Make instance publicly accessible (flag)
--name
: Function name (required)--runtime
: Runtime environment (required) - python3.9/python3.10/python3.11/nodejs18.x/nodejs20.x/java11/dotnet6--role
: IAM role ARN (required)--handler
: Function handler (default: lambda_function.lambda_handler)--code-file
: Path to code zip file (optional, creates Hello World if not provided)--description
: Function description (optional)--timeout
: Function timeout in seconds (optional)--memory
: Memory size in MB (optional)
--name
: Topic name (required)--display-name
: Topic display name (optional)
- Python 3.8+
- boto3 >= 1.26.0
- Valid AWS credentials
The tool provides clear error messages for common scenarios:
- Missing AWS credentials
- Resource already exists
- Invalid parameters
- AWS service errors
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
This project now includes a user-friendly web interface for creating AWS resources.
-
Install Flask:
pip install Flask
-
Run the application:
python -m aws_ui.app
Or, if installed via
pip install -e .
:aws-resources-web
-
Open your browser and navigate to
http://127.0.0.1:5000
.
- Create S3 buckets
- Launch EC2 instances
- Real-time feedback on resource creation status
Feito com ❤️ por Natália Granato.