Struct openapi_lambda_codegen::LambdaArn
source · pub struct LambdaArn(/* private fields */);
Expand description
Amazon Resource Name (ARN) for an AWS Lambda function.
This type represents an ARN either using variables (e.g., an AWS CloudFormation logical ID
constructed via the cloud_formation
method) or as a
fully-resolved ARN via the known
method. It is used to populate the
x-amazon-apigateway-integration
OpenAPI extensions that Amazon API Gateway uses to determine which Lambda function should handle
each API endpoint.
Implementations§
source§impl LambdaArn
impl LambdaArn
sourcepub fn cloud_formation<L>(logical_id: L) -> Self
pub fn cloud_formation<L>(logical_id: L) -> Self
Construct a variable ARN that references an AWS CloudFormation or Serverless Application Model (SAM) logical ID.
The logical ID should reference one of the following resource types defined in your CloudFormation/SAM template:
AWS::Serverless::Function
AWS::Lambda::Function
AWS::Lambda::Alias
(e.g., by appending.Alias
to the logical ID when specifying anAutoPublishAlias
on theAWS::Serverless::Function
resource)AWS::Lambda::Version
(e.g., by appending.Version
to the logical ID when specifying anAutoPublishAlias
on theAWS::Serverless::Function
resource)
When using this method, be sure to include the openapi-apigw.yaml
file in your
CloudFormation/SAM template with the AWS::Include
transform. Otherwise, the variables will
not be substituted during deployment, and deployment will fail. For example (where
.openapi-lambda
is the out_dir
passed to CodeGenerator::new
):
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
Name: my-api
StageName: prod
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: .openapi-lambda/openapi-apigw.yaml
Example
LambdaArn::cloud_formation("MyApiFunction.Alias")
sourcepub fn known<A, F, G, R>(
api_gateway_region: G,
account_id: A,
function_region: R,
function_name: F,
alias_or_version: Option<String>
) -> Self
pub fn known<A, F, G, R>( api_gateway_region: G, account_id: A, function_region: R, function_name: F, alias_or_version: Option<String> ) -> Self
Construct a fully-resolved AWS Lambda function ARN.
The resulting ARN does not depend on any CloudFormation variables and is compatible with any deployment method.
Arguments
api_gateway_region
- Region containing the Amazon API Gateway (e.g.,us-east-1
)account_id
- AWS account containing the AWS Lambda functionfunction_region
- Region containing the AWS Lambda function (e.g.,us-east-1
)function_name
- Name of the AWS Lambda functionalias_or_version
- Optional Lambda function version or alias
Example
LambdaArn::known(
"us-east-1",
"1234567890",
"us-east-1",
"my-api-function",
Some("live".to_string()),
)