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:
Retrieve the nx configuration for "docs:deploy-cf" (from targetName)
Calculate the stack name - taking into account the current stack suffix
Retrieve the stack outputs
So, for example if running nx deploy-s3 docs:
Retrieve the nx configuration for "docs-deploy-cf"
Re-create the stack name, in this case docs-dev because we're running with the default (dev) stackSuffix.
Retrieve outputs from the CloudFormation stack docs-dev
Get the values for WebBucket and DistributionId
Alternatively, if running nx deploy-s3 docs --configuration production:
Retrieve the nx configuration for "docs-deploy-cf"
Re-create the stack name, in this case docs-prod because we've over-ridden the default stackSuffix to prod
Retrieve outputs from the CloudFormation stack docs-prod
Add documentation for how the s3:deploy gets the bucket name and distro:
Take the following deploy target:
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:
targetName
)So, for example if running
nx deploy-s3 docs
:docs-dev
because we're running with the default (dev) stackSuffix.Alternatively, if running
nx deploy-s3 docs --configuration production
:docs-prod
because we've over-ridden the default stackSuffix to prod