Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3:deploy documentation #73

Open
studds opened this issue Mar 21, 2021 · 0 comments
Open

s3:deploy documentation #73

studds opened this issue Mar 21, 2021 · 0 comments

Comments

@studds
Copy link
Owner

studds commented Mar 21, 2021

Add documentation for how the s3:deploy gets the bucket name and distro:

Take the following deploy target:

{
  "deploy-s3": {
    "builder": "@nx-aws/s3:deploy",
    "options": {
      "destPrefix": "public",
      "bucket": {
        "targetName": "docs:deploy-cf",
        "outputName": "WebBucket"
      },
      "distribution": {
        "targetName": "docs:deploy-cf",
        "outputName": "DistributionId"
      }
    },
    "configurations": {
      "production": {
        "stackSuffix": "prod"
      }
    }
  }
}

To deploy to S3 we need an s3 bucket and then CloudFront distribution (so that we can trigger an invalidation of the deployed files.) We assume that there is a CloudFormation template which creates the S3 bucket and CF distribution, and outputs the web bucket name and distribution id as stack outputs. The configuration above then retrieves those outputs. It works like this:

  1. Retrieve the nx configuration for "docs:deploy-cf" (from targetName)
  2. Calculate the stack name - taking into account the current stack suffix
  3. Retrieve the stack outputs

So, for example if running nx deploy-s3 docs:

  1. Retrieve the nx configuration for "docs-deploy-cf"
  2. Re-create the stack name, in this case docs-dev because we're running with the default (dev) stackSuffix.
  3. Retrieve outputs from the CloudFormation stack docs-dev
  4. Get the values for WebBucket and DistributionId

Alternatively, if running nx deploy-s3 docs --configuration production:

  1. Retrieve the nx configuration for "docs-deploy-cf"
  2. Re-create the stack name, in this case docs-prod because we've over-ridden the default stackSuffix to prod
  3. Retrieve outputs from the CloudFormation stack docs-prod
  4. Get the values for WebBucket and DistributionId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant