diff --git a/docs/content/index.mdx b/docs/content/index.mdx index 26ab367ba4c..585ff0b4e5f 100644 --- a/docs/content/index.mdx +++ b/docs/content/index.mdx @@ -44,6 +44,19 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, SemanticVersion: 1.3.1 # change to latest semantic version available in SAR ``` +This will add a nested app stack with an output parameter `LayerVersionArn`, that you can reference inside your Lambda function definition: + +```yaml + Layers: + - !GetAtt AwsLambdaPowertoolsPythonLayer.Outputs.LayerVersionArn +``` + +You can fetch the available versions via the API with: + + ```bash + aws serverlessrepo list-application-versions --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer + ``` + ## Features Utility | Description diff --git a/example/README.md b/example/README.md index a54ab6ba3c3..b19f98f14f1 100644 --- a/example/README.md +++ b/example/README.md @@ -55,7 +55,7 @@ The first command will build the source of your application. The second command * **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. * **AWS Region**: The AWS region you want to deploy your app to. * **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. +* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. If you are using `AWS::Serverless::Application` as a layer, you need also to pass `CAPABILITY_AUTO_EXPAND` during `sam deploy`, because it will create a nested stack for the layer. * **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. You can find your API Gateway Endpoint URL in the output values displayed after deployment. diff --git a/example/template.yaml b/example/template.yaml index 47267d729f5..809e981edc0 100644 --- a/example/template.yaml +++ b/example/template.yaml @@ -17,6 +17,8 @@ Resources: CodeUri: hello_world/ Handler: app.lambda_handler Runtime: python3.8 + Layers: + - !GetAtt AwsLambdaPowertoolsPythonLayer.Outputs.LayerVersionArn Tracing: Active # enables X-Ray tracing Environment: Variables: @@ -33,6 +35,13 @@ Resources: Path: /hello Method: get + AwsLambdaPowertoolsPythonLayer: + Type: AWS::Serverless::Application + Properties: + Location: + ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer + SemanticVersion: 1.3.1 # change to latest semantic version available in SAR + Outputs: # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function # Find out more about other implicit resources you can reference within SAM