This repository shows how services can be published and shared across accounts.
The lash new public-bucket
command creates an S3 bucket that is publicly accessible, but requires requester to pay for transfer costs.
lash new public-bucket
NOTE: the S3 bucket name
my-public-bucket
must be globally unique. For the command to work, customize it to your needs.
Output:
LambdaSharp CLI (v0.8.2.2) - Create new public S3 bucket with Requester Pays access
|=> Enter the S3 bucket name: my-public-bucket
CREATE_COMPLETE AWS::CloudFormation::Stack Bucket-my-public-bucket (30.8s)
CREATE_COMPLETE AWS::S3::Bucket Bucket (22.4s)
CREATE_COMPLETE AWS::S3::BucketPolicy BucketPolicy (1.15s)
=> Stack creation finished
=> Updating S3 Bucket for Requester Pays access
=> S3 Bucket ARN: arn:aws:s3:::my-public-bucket
Done (finished: 3/18/2021 8:57:39 AM; duration: 00:00:39.5381551)
The lash init
command can associate a new deployment tier with an existing bucket, such as a public bucket.
lash init --tier Public
Output:
LambdaSharp CLI (v0.8.2.2) - Create or update a LambdaSharp deployment tier
Creating LambdaSharp tier 'Public'
Configuring LambdaSharp Core Resources (v0.8) Parameters
Enable LambdaSharp.Core services:
1. Enabled
2. Disabled
|=> Enter a choice: 2
|=> ARN of an existing S3 bucket for LambdaSharp deployments (leave blank to create a new bucket): arn:aws:s3:::my-public-bucket
=> Stack creation initiated for Public-LambdaSharp-Core
CREATE_COMPLETE AWS::CloudFormation::Stack Public-LambdaSharp-Core (4.43s)
=> Stack creation finished
=> Checking API Gateway role
Done (finished: 3/18/2021 9:37:16 AM; duration: 00:00:13.7116003)
lash publish --tier Public
LambdaSharp CLI (v0.8.2.2) - Publish LambdaSharp module
Reading module: Module.yml
Compiling: Acme.Bitcoin.PriceAnalyzer (v1.0-DEV)
=> Building function AnalyzeFunction [netcoreapp3.1, Release]
=> Module compilation done: bin\cloudformation.json
Publishing module: Acme.Bitcoin.PriceAnalyzer
=> Imported Bitcoin.Topic:1.0@serverlesspatterns
=> Imported Bitcoin.Event:1.0@serverlesspatterns
=> Uploading artifact: function_Acme.Bitcoin.PriceAnalyzer_AnalyzeFunction_651E2BE2416823A4DA1FB63B5FE9977D.zip
=> Uploading template: cloudformation_Acme.Bitcoin.PriceAnalyzer_FF53F0D4224794F919988715F75FD228.json
=> Published: Acme.Bitcoin.PriceAnalyzer:1.0-DEV@my-public-bucket
Done (finished: 3/18/2021 12:14:54 PM; duration: 00:00:12.6539034)
The lash new expiring-bucket
creates an S3 bucket that will self-delete after a period of time. The bucket is private and has a lifecycle policy that automatically delete any objects older than expiration period. A Lambda function is deployed in conjunction that checks the contents of the bucket every 6 hours. When the bucket is empty, the Lambda function deletes the stack with the bucket.
lash new expiring-bucket --expiration-in-days 3 my-build-bucket
NOTE: the S3 bucket name
my-build-bucket
must be globally unique. For the command to work, customize it to your needs.
Output:
LambdaSharp CLI (v0.8.2.2) - Create an S3 bucket that self-deletes after expiration
CREATE_COMPLETE AWS::CloudFormation::Stack Bucket-my-build-bucket (1m 45.96s)
CREATE_COMPLETE AWS::S3::Bucket Bucket (22.42s)
CREATE_COMPLETE AWS::IAM::Role AutoDeleteFunctionRole (19.76s)
CREATE_COMPLETE AWS::Lambda::Function AutoDeleteFunction (1.38s)
CREATE_COMPLETE AWS::Events::Rule AutoDeleteTimer (1m 1.39s)
CREATE_COMPLETE AWS::Lambda::Permission AutoDeleteTimerInvokePermission (10.8s)
=> Stack creation finished
=> S3 Bucket ARN: arn:aws:s3:::my-build-bucket
Done (finished: 3/18/2021 10:50:32 AM; duration: 00:01:49.8194187)
lash init --tier Build --core-services disabled --existing-s3-bucket-name my-build-bucket
Output:
LambdaSharp CLI (v0.8.2.2) - Create or update a LambdaSharp deployment tier
Creating LambdaSharp tier 'Build'
=> Stack creation initiated for Build-LambdaSharp-Core
CREATE_COMPLETE AWS::CloudFormation::Stack Build-LambdaSharp-Core (4s)
=> Stack creation finished
=> Checking API Gateway role
Done (finished: 3/18/2021 10:55:56 AM; duration: 00:00:08.2743317)
lash publish --tier Build --module-origin my-public-bucket