AWS Fundamentals LogoAWS Fundamentals
Back to Blog

Marrying Terraform and Serverless Framework by Using the Parameter Store

Tobias Schmidt
by Tobias Schmidt
Marrying Terraform and Serverless Framework by Using the Parameter Store

Table of Contents

Jump to a section

If you want to build a serverless application, the Serverless Framework gives you a head start if you want to have your service up and running fast. In very few lines of YAML, you’re able to configure Lambda functions and expose them via REST, HTTP, or event Socket Gateways. You’re able to attach authorizers easily and you can do a lot of fine-tuning like for example adding CloudWatch triggers for regularly invoking your functions to stay warm.

But what if your application ecosystems evolve around more than Lambda functions and gateways? Most likely you’ve used Terraform for provisioning and managing your infrastructure and I don’t need to highlight all of its awesome features. Surely, you could define your remaining infrastructure by extending your serverless.yml file with custom CloudFormation resources. But that’s not fun and you will miss Terraform soon.

There’s an easy way to combine both.

Getting the best of the two worlds

You can maintain all your infrastructure, excluding your Lambda functions and gateways, with Terraform and then just expose everything you need in your serverless functions via the Parameter Store. For example, if you want to use DynamoDB and its streams capability, just expose the ARN of the stream:

resource "aws_ssm_parameter" "stream_arn" {
  type        = "String"
  name        = "transaction-stream-arn"
  value       = aws_dynamodb_table.transaction.stream_arn
  overwrite   = true

  lifecycle {
    ignore_changes = [value]
  }
}

Afterward, you can use the exposed parameters in your serverless.yml via ${ssm.eu-central-1:/transaction-stream-arn}. The only thing you need to make sure is that your dependencies are always from your serverless infrastructure to infrastructure created via Terraform because you need to apply Terraform at first and you can’t have cyclic dependencies.

Combining Serverless Framework with Terraform via Parameter Store

That’s it. 🎉

AWS Lambda Infographic

AWS Lambda on One Page (No Fluff)

Skip the 300-page docs. Our Lambda cheat sheet covers everything from cold starts to concurrency limits - the stuff we actually use daily.

HD quality, print-friendly. Stick it next to your desk.

Privacy Policy
By entering your email, you are opting in for our twice-a-month AWS newsletter. Once in a while, we'll promote our paid products. We'll never send you spam or sell your data.

If you found this article on marrying Terraform and Serverless Framework insightful, you might also enjoy these related posts:

Related Posts

Discover similar content using semantic vector search powered by AWS S3 Vectors. These posts share conceptual similarities based on machine learning embeddings.

vector_search.sh
~/blog/related-posts
$ aws s3-vectors query --embedding-model titan --index bedrock-kb-default --similarity cosine --top-k 3
✓ Found 3 semantic matches:
[MATCH_1]
cosine_similarity:0.888649
vector_dim: 1536 | euclidean_dist: 0.223
Building a Real-World Use Case with Step Functions and the Callback Pattern
cover.webp...
Building a Real-World Use Case with Step Functions and the Callback Pattern
aws_service:lambdatimestamp:2024-03-12
slug: /blog/building-a-real-world-use-case-with-step-functions-and-the-callback-patternembedding_match: 88.86%
[MATCH_2]
cosine_similarity:0.802550
vector_dim: 1536 | euclidean_dist: 0.395
Introduction to AWS Lambda: A Starter Guide
cover.webp...
Introduction to AWS Lambda: A Starter Guide
aws_service:lambdatimestamp:2021-05-27
slug: /blog/starter-guide-things-i-wish-i-knew-before-for-aws-lambdaembedding_match: 80.26%
[MATCH_3]
cosine_similarity:0.755405
vector_dim: 1536 | euclidean_dist: 0.489
Render - Modern Cloud without the Ops and Complexity
cover.webp...
Render - Modern Cloud without the Ops and Complexity
aws_service:lambdatimestamp:2025-07-07
slug: /blog/render-modern-cloud-without-the-opsembedding_match: 75.54%
Query executed in ~48ms
Powered by AWS S3 Vectors
$ _

Related Posts

⚡ Powered by AWS S3 Vectors
AWS Lambda Infographic

AWS Lambda on One Page (No Fluff)

Skip the 300-page docs. Our Lambda cheat sheet covers everything from cold starts to concurrency limits - the stuff we actually use daily.

HD quality, print-friendly. Stick it next to your desk.

Privacy Policy
By entering your email, you are opting in for our twice-a-month AWS newsletter. Once in a while, we'll promote our paid products. We'll never send you spam or sell your data.