# aws-domain-redirect

> A simple project to programmatically redirect a domain to a specific URL using AWS Route53 and AWS S3 Static Websites.

Latest version **2.0.0** (published 2022-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-domain-redirect
pnpm add aws-domain-redirect
yarn add aws-domain-redirect
bun add aws-domain-redirect
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-07-26 |
| First published | 2022-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dolox, Inc. |
| Maintainers | sgarbesi |

## Links

- npm: https://www.npmjs.com/package/aws-domain-redirect
- Repository: https://github.com/dolox/aws-domain-redirect
- Homepage: https://github.com/dolox/aws-domain-redirect#readme
- Issues: https://github.com/dolox/aws-domain-redirect/issues
- npm.io page: https://npm.io/package/aws-domain-redirect

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [chalk](https://npm.io/package/chalk.md) ^5.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1161.0

## Recent versions

- 2.0.0 (latest) — 2022-07-26
- 1.0.0 — 2022-06-26

## README

# aws-domain-redirect

A simple project to programmatically redirect a domain to a specific URL using AWS Route53 and AWS S3 Static Websites.

---

## Usage

**Install the node package:**

```bash
yarn add aws-domain-redirect;
```

**Redirect a Domain:**

```javascript
import AWSDomainRedirect from "aws-domain-redirect";
import config from "./config.js";

(async () => {
  const awsDomainRedirect = new AWSDomainRedirect(config);
  await awsDomainRedirect.Run("www.dolox.com", "dolox.com", "https://www.dolox.com/");
})();
```

---

## Configuration

| Key                                | Type      | Description                                                                                                  |
| ---------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------ |
| `aws.accessKeyId`                  | `string`  | Your AWS access key ID.                                                                                      |
| `aws.accessKeyId`                  | `string`  | Your AWS secret access key.                                                                                  |
| `aws.route53.DNSName`              | `string`  | The AWS S3 Bucket DNS Name. See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html |
| `aws.route53.EvaluateTargetHealth` | `boolean` | See: https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html                            |
| `aws.route53.HostedZoneId`         | `string`  | See: https://docs.aws.amazon.com/sdk-for-ruby/v1/api/AWS/Route53/HostedZone.html                             |

**Example:**

```json
{
  "aws": {
    "accessKeyId": "...",
    "secretAccessKey": "...",

    "route53": {
      "DNSName": "s3-website-us-east-1.amazonaws.com.",
      "EvaluateTargetHealth": false,
      "HostedZoneId": "Z3AQBSTGFYJSTF"
    }
  }
}
```

---

## API

### async Run(domain, hostedZoneName, redirectUrl)

This Function will invoke the process of creating a bucket with the static website hosting redirect along with a hosted zone record. 

*Function Parameters:*

| Key            | Type     | Description                                |
| -------------- | -------- | ------------------------------------------ |
| domain         | `string` | The record name for the hosted zone entry. |
| hostedZoneName | `string` | The name of the hosted zone.               |
| redirectUrl    | `string` | The URL to redirect to.                    |

The Function will return an Object on success, or will throw an error upon failure.

*Return Object:*

| Key                 | Type     | Description                                   |
| ------------------- | -------- | --------------------------------------------- |
| bucketCreate        | `object` | Results from creating the bucket.             |
| bucketUpdateWebsite | `object` | Results from updating the bucket website.     |
| zoneCreate          | `object` | Results from creating the hosted zone.        |
| zoneRecordCreate    | `object` | Results from creating the hosted zone record. |

---

## AWS Permissions

This project needs access to programmatically:

- Read/Write AWS Route53 Hosted Zones
- Read/Write AWS Route53 Hosted Zone Records
- Read/Write AWS S3 Buckets
- Read/Write AWS S3 Static Website Redirects

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "aws-domain-redirect",
      "Effect": "Allow",
      "Action": [
        "route53:GetChange",
        "route53:GetHostedZone",
        "route53:ChangeResourceRecordSets",
        "route53:ListResourceRecordSets",
        "route53:DeleteHostedZone"
      ],
      "Resource": [
        "arn:aws:route53:::hostedzone/*",
        "arn:aws:route53:::change/*"
      ]
    },
    {
      "Sid": "VisualEditor1",
      "Effect": "Allow",
      "Action": [
        "route53:CreateHostedZone",
        "s3:GetBucketWebsite",
        "s3:PutBucketWebsite",
        "route53:ListHostedZones",
        "s3:CreateBucket",
        "s3:ListBucket"
      ],
      "Resource": "*"
    }
  ]
}
```

---

Copyright (c) 2022 Dolox, Inc.

---
_Source: https://npm.io/package/aws-domain-redirect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
