Skip to content

sealedloveproject/aws-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS S3 & SNS Automation for Sealed Love Project

This Node.js application automates the setup of AWS S3 buckets, replication, IAM users, and SNS notifications for the Sealed Love project.

Features

  • Creates IAM users with appropriate permissions
  • Sets up S3 buckets in all AWS regions with consistent naming
  • Configures replication from regional buckets to a central bucket
  • Creates SNS topics with HTTPS subscriptions for notifications
  • Supports the required bucket structure: /stories/{env}/{UUID}/

Prerequisites

  • Node.js (v14 or higher)
  • AWS account with administrative access
  • AWS credentials configured locally
  • AWS SDK v3 (installed via npm)

Installation

  1. Clone this repository
  2. Run npm install to install dependencies
  3. Create a .env file with your AWS credentials (see .env.example)

Usage

You can run the setup using npm scripts or directly with Node.js:

Using npm scripts

# Run the complete setup
npm start

# Run specific parts of the setup
npm run users        # Only create IAM users
npm run buckets      # Only create S3 buckets
npm run sns          # Only create SNS topics and subscriptions
npm run replication  # Only configure bucket replication

# Clean up all resources created by this script
npm run cleanup

Using Node.js directly

# Run the complete setup
node index.js

# Run specific parts of the setup
node index.js --users-only
node index.js --buckets-only
node index.js --sns-only
node index.js --replication-only

# Clean up all resources created by this script
node index.js --cleanup

Configuration

Edit the config.js file to customize:

  • Target AWS regions
  • Bucket naming
  • SNS endpoints
  • IAM user names and policies

Technical Implementation

AWS SDK v3

This project uses AWS SDK v3, which offers several advantages over v2:

  • Modular architecture: Only import the services you need
  • Reduced bundle size
  • Improved TypeScript support
  • Command-based API design

Example of AWS SDK v3 usage in this project:

// Creating an S3 bucket with AWS SDK v3
const { S3Client, CreateBucketCommand } = require('@aws-sdk/client-s3');

const s3Client = new S3Client({ region });
const params = { Bucket: bucketName };

// Special handling for us-east-1 region
if (region !== 'us-east-1') {
  params.CreateBucketConfiguration = { LocationConstraint: region };
}

await s3Client.send(new CreateBucketCommand(params));

Cleanup Process

To remove all AWS resources created by this script, run:

npm run cleanup

This will delete resources in the following order:

  1. Remove S3 event notifications from buckets
  2. Delete SNS topics and subscriptions
  3. Delete S3 buckets (including emptying all objects and versions)
  4. Delete IAM users, their access keys, and attached policies
  5. Delete IAM roles used for replication

Security Notes

  • The created IAM users will have access keys generated
  • Save the access keys securely as they will only be shown once
  • The IAM users have the minimum permissions required for their roles

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published