From f636de3ee8fbbd611793eb5fc37d0379ad3eef7a Mon Sep 17 00:00:00 2001 From: pratik hanmante Date: Fri, 28 Mar 2025 08:17:46 +0000 Subject: [PATCH 1/5] cfn --- s3/iac/cfn/deploy | 3 ++- s3/iac/cfn/deploy1 | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 s3/iac/cfn/deploy1 diff --git a/s3/iac/cfn/deploy b/s3/iac/cfn/deploy index 6f46d67d..1f66b641 100755 --- a/s3/iac/cfn/deploy +++ b/s3/iac/cfn/deploy @@ -8,4 +8,5 @@ aws cloudformation deploy \ --template-file template.yaml \ --no-execute-changeset \ --region us-west-2 \ ---stack-name $STACK_NAME \ No newline at end of file +--stack-name $STACK_NAME + diff --git a/s3/iac/cfn/deploy1 b/s3/iac/cfn/deploy1 new file mode 100755 index 00000000..ae230df3 --- /dev/null +++ b/s3/iac/cfn/deploy1 @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +echo "== deploy s3 bucket via CFN " + +STACK_NAME="cfn-s3-simple" + +aws cloudformation deploy \ +--template-file template.yaml \ +--no-execute-changeset \ +--region us-west-2 \ +--stack-name $STACK_NAME + From 42302508b81cc5a70193dda840120f6984a4120e Mon Sep 17 00:00:00 2001 From: pratik hanmante Date: Thu, 17 Jul 2025 09:28:49 +0000 Subject: [PATCH 2/5] added the commands for create ,delete bucket and list,put objects in the script --- pratik/s3/bash-scripts/all-scripts.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pratik/s3/bash-scripts/all-scripts.txt diff --git a/pratik/s3/bash-scripts/all-scripts.txt b/pratik/s3/bash-scripts/all-scripts.txt new file mode 100644 index 00000000..67920065 --- /dev/null +++ b/pratik/s3/bash-scripts/all-scripts.txt @@ -0,0 +1,14 @@ +//creating bucket +//these scripting files and the data related to the buckets will be stored in the /temp + +aws s3api create-bucket --bucket $BUCKET_NAME //we can name the bucket after run + +//deleting bucket + +aws s3api delete-bucket --bucket $BUCKET_NAME //we can name bucket during the execution + +//listing objects + +aws s3api list-objects-v2 --bucket $BUCKET_NAME + +/puting data into the file From 5485c72167587c59ae020d444301b95b98c91d96 Mon Sep 17 00:00:00 2001 From: pratik hanmante Date: Thu, 17 Jul 2025 10:29:00 +0000 Subject: [PATCH 3/5] ++powerhell s3 commands --- pratik/s3/bash-scripts/all-scripts.txt | 22 ++++++++++++++++++++++ pratik/s3/powershell/all-scripts.txt | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pratik/s3/powershell/all-scripts.txt diff --git a/pratik/s3/bash-scripts/all-scripts.txt b/pratik/s3/bash-scripts/all-scripts.txt index 67920065..e1b5204a 100644 --- a/pratik/s3/bash-scripts/all-scripts.txt +++ b/pratik/s3/bash-scripts/all-scripts.txt @@ -12,3 +12,25 @@ aws s3api delete-bucket --bucket $BUCKET_NAME //we can name bucket during the ex aws s3api list-objects-v2 --bucket $BUCKET_NAME /puting data into the file +#!/usr/bin/env bash +echo "== put-object" + +# Check for bucket name +if [ -z "$1" ]; then + echo "There needs to be a bucket name eg. ./bucket my-bucket-name" + exit 1 +fi + +if [ -z "$2" ]; then + echo "There needs to be a filename eg. ./bucket my-bucket-name filename" + exit 1 +fi +BUCKET_NAME=$1 +FILENAME=$2 + +OBJECT_KEY=$(basename "$FILENAME") + +aws s3api put-object \ +--bucket $BUCKET_NAME \ +--body $FILENAME \ +--key $OBJECT_KEY diff --git a/pratik/s3/powershell/all-scripts.txt b/pratik/s3/powershell/all-scripts.txt new file mode 100644 index 00000000..cfdfa9d5 --- /dev/null +++ b/pratik/s3/powershell/all-scripts.txt @@ -0,0 +1,12 @@ +--create bucket + +Import-Module AWS.Tools.s3api +$region = "us-east-1" + +$bucketName = Read-Host Prompt 'Enter the S3 bucket name' + +Write-Host "AWS Region : $region" +Write-Host "S3 Bucket: $bucketName" + +New-S3Bucket -Bucketname $bucketName -Region $region + From c75c12a89c84c5cefe070a0e9fe83adb34ade07b Mon Sep 17 00:00:00 2001 From: pratik hanmante Date: Wed, 23 Jul 2025 12:28:37 +0000 Subject: [PATCH 4/5] ++ cdk and tf --- package-lock.json | 6 ++++++ pratik/s3/CDK | 35 +++++++++++++++++++++++++++++++++++ s3/iac/cdk/lib/cdk-stack.ts | 7 +++++++ s3/iac/terraform/main.tf | 3 +++ 4 files changed, 51 insertions(+) create mode 100644 package-lock.json create mode 100644 pratik/s3/CDK diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..c5530b6f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "AWS-Examples", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/pratik/s3/CDK b/pratik/s3/CDK new file mode 100644 index 00000000..11ac84c8 --- /dev/null +++ b/pratik/s3/CDK @@ -0,0 +1,35 @@ +// for installing + +// npm install +// npm i -g aws-cdk + +import * as cdk from 'aws-cdk-lib'; +import { Bucket, BucketPolicy } from 'aws-cdk-lib/aws-s3'; + +{ + "name": "my-package", + "version": "0.1.0", + "bin": { + "my-package": "bin/my-package.js" + }, + "scripts": { + "build": "tsc", + "watch": "tsc -w", + "test": "jest", + "cdk": "cdk" + }, + "devDependencies": { + "@types/jest": "^26.0.10", + "@types/node": "10.17.27", + "jest": "^26.4.2", + "ts-jest": "^26.2.0", + "aws-cdk": "2.16.0", + "ts-node": "^9.0.0", + "typescript": "~3.9.7" + }, + "dependencies": { + "aws-cdk-lib": "2.16.0", + "constructs": "^10.0.0", + "source-map-support": "^0.5.16" + } +} \ No newline at end of file diff --git a/s3/iac/cdk/lib/cdk-stack.ts b/s3/iac/cdk/lib/cdk-stack.ts index 3ea936cf..109bbfc9 100644 --- a/s3/iac/cdk/lib/cdk-stack.ts +++ b/s3/iac/cdk/lib/cdk-stack.ts @@ -8,3 +8,10 @@ export class CdkStack extends Stack { const bucket = new s3.Bucket(this, 'MyBucket'); } } + +export class CdkStack extends Stack { + constructor(scope: Construct, id: String, props?: StackProps) { + super(scope,id,props) + const bucket = new s3.Bucket(this, 'MyBucket') + } +} diff --git a/s3/iac/terraform/main.tf b/s3/iac/terraform/main.tf index 45cfedea..d19db235 100644 --- a/s3/iac/terraform/main.tf +++ b/s3/iac/terraform/main.tf @@ -9,4 +9,7 @@ terraform { provider "aws" { # Configuration options +} + +resource "aws_s3_bucket" "default" { } } \ No newline at end of file From 09be971c50cf1c1e1656015b0af350979d28071e Mon Sep 17 00:00:00 2001 From: pratik hanmante Date: Sat, 26 Jul 2025 10:50:44 +0000 Subject: [PATCH 5/5] ++ --- .vscode/settings.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..b242572e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ] +} \ No newline at end of file