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:StringVpcConfig:VpcConfigOperatorRole:StringTags:MapPropagateTags:BooleanInstanceRequirements:InstanceRequirementsScalingConfig:ScalingConfigKMSKeyArn: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
CapacityProviderNameproperty of anAWS::Lambda::CapacityProviderresource. -
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
VpcConfigproperty of anAWS::Lambda::CapacityProviderresource. -
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
PermissionsConfigproperty of anAWS::Lambda::CapacityProviderresource. -
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
Tagsproperty of anAWS::Lambda::CapacityProviderresource. TheTagsproperty 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 alambda:createdBy:SAMtag to this Lambda function, and to the default roles generated for this function. -
Indicates whether or not to pass tags from the Tags property to your
AWS::Serverless::CapacityProvidergenerated resources. Set this toTrueto 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
allowedorexcludedinstance 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
CapacityProviderScalingConfigproperty of anAWS::Lambda::CapacityProviderresource -
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
KmsKeyArnproperty of anAWS::Lambda::Functionresource.
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-providerVpcConfig: SubnetIds: -subnet-12345678-subnet-87654321SecurityGroupIds: -sg-12345678Tags: 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-providerVpcConfig: SubnetIds: -subnet-12345678-subnet-87654321SecurityGroupIds: -sg-12345678OperatorRole: arn:aws:iam::123456789012:role/MyCapacityProviderRolePropagateTags: 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-123456789012Tags: Environment: Production CostCenter: Engineering