Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

nearform/mira-sample-s3-webhosting

Repository files navigation

Mira S3 Webhosting Sample Application

This application is a very basic application, that provides a ready-to-use project setup for the Mira accelerator.

The successful deployment of this project will create an S3 bucket with web hosting enabled and a single index.html file in it, which will output a 'hello world' message.

This sample app is recommended primarily for evaluation purposes, and project owners who want the benefits of Mira CI orchestration but wish to make a clean start with their project.

Getting Started

  1. Generate your own project repository from this repo mira-sample-s3-webhosting

    ⚠️ Remember to make your new repository 🕵🏻‍♀️ Private as you store potentially sensitive information in the Mira configuration files.

  2. Clone your newly created repository

  3. Ensure that you are using Node.js v12 (v14 should work too, but is untested here):

    % node --version
    v12.21.0

    or, if using [nvm]:

    % nvm use
    Now using node v12.21.0 (npm v6.14.11)
  4. Install the required dependencies

    Make sure you use the supported version of the CDK (1.89.0) and all the required dependencies are included in your package.json file. See the Mira documentation for the full list.

    Note: It is a known constraint of CDK that the usage of its version number must be exact. Range operators for the version will cause your sample to break, e.g. ^1.89.0 is not the same as 1.89.0.

  5. Build

    npm run build
  6. Set up your config file

    cp config/default.sample.json config/default.json
  7. Adjust config/default.json with your settings

    1. Update the app and dev sections with your desired values e.g.:
      "app": {
         "prefix": "big-company",
         "name": "super-app"
       },
      "dev": {
          "target": "default"
      }
    2. Update the accounts section to at least include settings for your default (name specified as a target in dev section) deployment e.g.:
      "accounts": {
        "default": {
          "env": {
            "account": "11111111111",
            "region": "eu-west-1"
          },
          "profile": "mira-dev"
        }
      }
  8. If you are working as part of a team, create a config/dev.json file and provide your own app settings e.g.:

    "app": {
       "prefix": "john",
       "name": "super-app"
     }

    Note: config/dev.json file is specific to your personal setup and should not be tracked in GIT.

  9. Bootstrap AWS CDK on the target AWS account and region, i.e.:

    cdk bootstrap aws://YOUR_NUMBER/YOUR_REGION --profile YOUR_PROFILE

    Note: If CDK is already bootstrapped, you can skip this step.

  10. Deploy

    npm run deploy

    Note: The default tags will be associated to that stack: StackName, CreatedBy (Owner) and CostCenter (If defined).

    At this step you should have your development environment deployed and ready to use.

  11. (Optional) Setup CI

    See the quickstart section of the Mira documentation for details.

    Note: If also setting up CI, then be aware that, by default, repository mirroring is disabled. Go to .github/workflows/mirror.yml and follow the comment there.

Mira Docs

Run npx mira docs and navigate to http://localhost:3000/ for more information about Mira.

Note: The default port may be already taken; if the above website is not available then please check your terminal logs for the correct address.

Project specific files

  • infra/src/index.ts - your stack definition.
  • infra/src/permissions.ts - your stack with IAM permissions needed to deploy the app with CI.
  • infra/src/buildspec.yaml - Build specification reference for CodeBuild.
  • config/default.sample.json - example configuration file (rename to default.json to use)
  • config/dev.json - local development configuration file that overrides default.json.