Struct 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

Source

pub fn cloud_formation<L>(logical_id: L) -> Self
where L: Into<String>,

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:

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")
Source

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
where A: Into<String>, F: Into<String>, G: Into<String>, R: Into<String>,

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 function
  • function_region - Region containing the AWS Lambda function (e.g., us-east-1)
  • function_name - Name of the AWS Lambda function
  • alias_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()),
)

Trait Implementations§

Source§

impl Debug for LambdaArn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.