diff --git a/guard-lambda/README.md b/guard-lambda/README.md index 80ef15b12..98019d554 100644 --- a/guard-lambda/README.md +++ b/guard-lambda/README.md @@ -123,12 +123,50 @@ The Lambda version of the tool is a lightweight wrapper around the core [cfn-gua ### Building and deploying +#### Guided + 1. Make sure docker is running 2. Navigate to `guard-lambda` directory and run `sam build --use-container` to build the code for the Lambda function 3. Run `sam deploy --guided` and complete the interactive workflow. This workflow will create a CloudFormation changeset and deploy it 4. Once it succeeds, the name of the function will be shown in the `CloudFormationGuardLambdaFunctionName` output 5. For subsequent updates, build the code again (step 2) and run `sam deploy` (without `--guided`) +#### CI/CD + +This approach does not require user input and can be used in CI/CD pipelines: + +1. Make sure docker is running +2. Navigate to `guard-lambda` directory and run `sam build --use-container` to build the code for the Lambda function +3. Run `sam package --s3-bucket ` this will create a `.zip` package with the code and dependencies and upload to S3 +4. Run `sam deploy --s3-bucket --stack-name \ + --stack-name \ + --parameter-overrides FunctionName=MyCfnGuardLambda +``` + +or in your `samconfig.toml`: + +```toml +[default.global.parameters] +s3_bucket = "" +stack_name = "" +parameter_overrides = "FunctionName=MyCfnGuardLambda" +``` + +Note: multiple parameters are separated by spaces: `Param1=Value1 Param2=Value2` ## Calling the AWS Lambda Function diff --git a/guard-lambda/template.yaml b/guard-lambda/template.yaml index a79a90eab..039e65a94 100644 --- a/guard-lambda/template.yaml +++ b/guard-lambda/template.yaml @@ -1,11 +1,17 @@ Transform: AWS::Serverless-2016-10-31 +Parameters: + FunctionName: + Type: String + Description: The name of the function + Resources: CloudFormationGuardLambda: Type: AWS::Serverless::Function Properties: Runtime: provided.al2 Handler: guard.handler + FunctionName: !Ref FunctionName # We need to point to the parent directory, so we can use ../guard/* CodeUri: .. Environment: