Skip to content

DimitriosKay/Boto3_Playground

Repository files navigation

AWS infrastructure setup using Python and Boto3

Basic implementation (primarily a study)

Started off with few dabble scripts, bringing up and deleting an S3 bucket and an EC2 instance:

Run the files with a standard python3 filename.py
  • ec2_spawn - Create the instance and run a .create_tags which allows you to specify the name of the instance
  • ec2_del - Run the script, paste your instance ID, Enter ... Profit
  • s3_spawn - Create bucket with name specified, in the location specified, then call the .upload_file
  • s3_del - Fetches the bucket name, checks files in bucket(iterates through objects.all), removes them(objects.delete) and deletes the bucket
  • test_s3_check.py - My study file, when I was going thorugh the documentation.
    • Object referes to a file in the bucket,
    • Action can read the file we fetch with the previous command,
    • Atributes can be .last_modified or .e_tag

Developed the boto3_proj while learning from a Udemy AWS course:

Here we run python3 deploy.py or to run a specific service (eg. _instance() classes or the main() vpc infrastructure) comment out statements at the bottom of the file
vpc and ec2 deployment
  • Create VPC and infrastructure
  • Adding two EC2 instances
  • ...
How to Run:
  • To bring up the infrastructure run deploy.py
  • If you wanna dabble with the setups of the infra, the file has method calls at the end which can be commented out
  • To destroy the infrastructure, run ec2_destroy.py
s3 deployment:
  • Creating a bucket, with general setting for example purposes (allowing you to pick and choose what policies you want)
  • Assigning and updating stock policies
  • Checking properties, listing isntances, checking available, handling error (allowing encryption if none is found)
  • Single and multi stage file uploading
  • Versioning of files and lifecycle policies
  • Setting up a modular S3 webpage hosting service (can edit the index.html file, run again and it will push the changes nicely)
How to Run:
  • For base S3 bucket setup, at the bottom of the s3_deploy.py file comment out everything under 'Create S3 infrastructure' and run python3 s3_deploy.py
  • For S3 hosted web page, comment out everything under 'Deploy bucket hosted webpage' and run python3 s3_deploy.py
  • Service cleanup (except for VPC network - for now):
    • Destroy file created s3_destroy.py. If you wanna destroy the infrastructure, run the file.
    • ... Voilah

[] Was (sort of still am) trying to make sense of when to use client or resource in the boto3.client/resource calls

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published