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 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/pratik/s3/bash-scripts/all-scripts.txt b/pratik/s3/bash-scripts/all-scripts.txt new file mode 100644 index 00000000..e1b5204a --- /dev/null +++ b/pratik/s3/bash-scripts/all-scripts.txt @@ -0,0 +1,36 @@ +//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 +#!/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 + 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/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 + 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