Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Invoke cross account Lambda function directly via Step Functions

Created with SnapAWS Account 1AWS Step FunctionsAWS Account 2AWS Lambda

Create a Step Functions workflow which invokes cross account Lambda function

This sample pattern allows users from one account to invoke their Lambda function present in a different account via Step Functions and retrieve the desired output.
This is highly efficient and useful when it comes to pulling cross account data all in one place.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}


variable "region" {}
variable "prefix" {}

# Configure the AWS Provider
provider "aws" {
 profile = "default"
 region  = "${var.region}"
 alias   = "default"
}
 
#cross account
provider "aws" {
 profile = "crossaccount"
 region  = "${var.region}"
 alias   = "crossaccount"
}

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/sfn-lambda-function-crossaccount-terraform

Deploy

terraform initterraform apply


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

terraform destroy
terraform show

Shivam Rajawat

Presented by Shivam Rajawat

I am a Cloud Support Engineer (Serverless) at AWS and I love to simplify complex stuff.

Follow on LinkedIn