AWS::Serverless::CapacityProvider - Amazon Serverless Application Model
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::Serverless::CapacityProvider

Creates a capacity provider for Amazon Lambda functions that enables running Lambda Managed Instances on customer-owned Amazon Elastic Compute Cloud instances. This resource is part of the Lambda Managed Instances feature, which provides cost optimization for large-scale Lambda workloads by utilizing EC2 pricing models.

The capacity provider manages the lifecycle of EC2 instances and provides the necessary infrastructure for Lambda functions to execute on customer-owned compute resources while maintaining the serverless programming model.

Note

When you deploy to Amazon CloudFormation, Amazon SAM transforms your Amazon SAM resources into Amazon CloudFormation resources. For more information, see Generated Amazon CloudFormation resources for Amazon SAM.

Syntax

To declare this entity in your Amazon Serverless Application Model (Amazon SAM) template, use the following syntax.

YAML

Type: AWS::Serverless::CapacityProvider Properties: CapacityProviderName: String VpcConfig: VpcConfig OperatorRole: String Tags: Map PropagateTags: Boolean InstanceRequirements: InstanceRequirements ScalingConfig: ScalingConfig KMSKeyArn: String

Properties

CapacityProviderName

The name of the capacity provider. This name must be unique within your Amazon account and region.

Type: String

Required: No

Amazon CloudFormation compatibility: This property is similar to the CapacityProviderName property of an AWS::Lambda::CapacityProvider resource.

VpcConfig

The VPC configuration for the capacity provider. Specifies the VPC subnets and security groups where Amazon EC2 instances will be launched.

Type: VpcConfig

Required: Yes

Amazon CloudFormation compatibility: This property is passed directly to the VpcConfig property of an AWS::Lambda::CapacityProvider resource.

OperatorRole

The ARN of the operator role for Lambda with permissions to create and manage Amazon EC2 instances and related resources in the customer account. If not provided, Amazon SAM automatically generates a role with the necessary permissions.

Type: String

Required: No

Amazon CloudFormation compatibility: This property is passed directly to the PermissionsConfig property of an AWS::Lambda::CapacityProvider resource.

Tags

A map of key-value pairs to apply to the capacity provider and its associated resources.

Type: Map

Required: No

Amazon CloudFormation compatibility: This property is passed directly to the Tags property of an AWS::Lambda::CapacityProvider resource. The Tags property in Amazon SAM consists of key-value pairs (whereas in Amazon CloudFormation this property consists of a list of Tag objects). Also, Amazon SAM automatically adds a lambda:createdBy:SAM tag to this Lambda function, and to the default roles generated for this function.

PropagateTags

Indicates whether or not to pass tags from the Tags property to your AWS::Serverless::CapacityProvider generated resources. Set this to True to propagate tags in your generated resources.

Type: Boolean

Required: No

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

InstanceRequirements

Specifications for the types of compute instances that the capacity provider can use. This includes architecture requirements and allowed or excluded instance types.

Type: InstanceRequirements

Required: No

Amazon CloudFormation compatibility: Amazon SAM maps this property to InstanceRequirements.

ScalingConfig

The scaling configuration for the capacity provider. Defines how the capacity provider scales Amazon EC2 instances based on demand.

Type: ScalingConfig

Required: No

Amazon CloudFormation compatibility: This property is passed directly to the CapacityProviderScalingConfig property of an AWS::Lambda::CapacityProvider resource

KMSKeyArn

The ARN of the Amazon KMS key used to encrypt data at rest and in transit for the capacity provider.

Type: String

Required: No

Amazon CloudFormation compatibility: This property is passed directly to the KmsKeyArn property of an AWS::Lambda::Function resource.

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, it returns the name of the capacity provider.

For more information about using the Ref function, see Ref in the Amazon CloudFormation User Guide.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using Fn::GetAtt, see Fn::GetAtt in the Amazon CloudFormation User Guide.

Arn

The ARN of the capacity provider.

Examples

Basic capacity provider

The following example creates a basic capacity provider with VPC configuration.

MyCapacityProvider: Type: AWS::Serverless::CapacityProvider Properties: CapacityProviderName: my-capacity-provider VpcConfig: SubnetIds: - subnet-12345678 - subnet-87654321 SecurityGroupIds: - sg-12345678 Tags: Environment: Production Team: ServerlessTeam

Advanced capacity provider with scaling

The following example creates a capacity provider with custom instance requirements and scaling configuration.

AdvancedCapacityProvider: Type: AWS::Serverless::CapacityProvider Properties: CapacityProviderName: advanced-capacity-provider VpcConfig: SubnetIds: - subnet-12345678 - subnet-87654321 SecurityGroupIds: - sg-12345678 OperatorRole: arn:aws:iam::123456789012:role/MyCapacityProviderRole PropagateTags: true InstanceRequirements: Architectures: - x86_64 ExcludedTypes: - t2.micro ScalingConfig: MaxInstanceCount: 10 ManualScalingPolicies: AverageCPUUtilization: 70.0 KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012 Tags: Environment: Production CostCenter: Engineering