[{"data":1,"prerenderedAt":210},["ShallowReactive",2],{"content-guides-building-serverless-applications-with-terraform-02-solution-overview":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":22,"contributorPaths":23,"menuType":28,"contentName":29,"slug":30,"readingTime":31,"menu":32,"nextDocItem":60,"previousDocItem":36},"\u003Cp>Throughout this guide, you will learn how to use Terraform to build a Serverless application that is used to generate greeting cards for employees working in a fictitious enterprise named AcmeCorp. In the final chapter you can download the sample code used in this guide, as well as get a collection of actionable resources to continue your learning journey. \u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fassets\u002Fexternal\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002Fassets\u002Fsolution-architecture.png\" alt=\"\">\u003C\u002Fp>\n\u003Cp>Each chapter of this guide builds on the previously created solution, adds a new concept, and explains how to wire it with existing components. Note that this guide is not intended to be consumed as a step-by-step workshop or tutorial, its purpose is to illustrate and provide guidance through the concepts you can use to create your own Serverless applications. \u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Chapter 3\u003C\u002Fstrong> illustrates configuring Terraform and using it to create \u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Fs3\u002F\">Amazon S3\u003C\u002Fa> buckets - one for storing employee photos (source bucket), the other for storing generated greeting cards (target bucket).\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Chapter 4\u003C\u002Fstrong> shows how to create an \u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Flambda\u002F\">AWS Lambda\u003C\u002Fa> function that receives an array of employee IDs and generates greeting cards. The function will retrieve photos from the source bucket, generate greeting cards, and store them in the target bucket. Initially you&#39;ll invoke that function manually using the AWS CLI.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Chapter 5\u003C\u002Fstrong> explains how to make the application more consumable by other parts of the business by exposing the functionality via \u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Fapi-gateway\u002F\">Amazon API Gateway\u003C\u002Fa>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Chapter 6\u003C\u002Fstrong> introduces additional resiliency and scalability into the architecture by adding an \u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Fsqs\u002F\">Amazon SQS\u003C\u002Fa> queue to generate greeting cards asynchronously. This would help during the holiday season, when the app needs to generate greeting cards for thousands of employees.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Chapter 7 and 8\u003C\u002Fstrong> focus on operational aspects of the application, such as observability, deploying to multiple environments and more.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2>Identity and Access Management\u003C\u002Fh2>\n\u003Cp>When building applications on AWS, it is important you take care of IAM permissions in order to only allow resources you permit to communicate with each other. For example, you will need to grant your Lambda function permissions to poll (but not push) messages from the SQS queue, as well as read from and write to S3 buckets. \u003C\u002Fp>\n\u003Cp>As a general practice, the guide follows the principle of least privileged access. Each step demonstrates how to grant the minimal required set of permissions. The guide will demonstrate how to use a combination of execution roles and resource policies. For example, the Lambda function will have an execution role allowing it to poll messages from the SQS Queue, and SQS Queue will have a resource policy allowing API Gateway to send messages. Read more about using \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Fiam\u002F\">AWS IAM\u003C\u002Fa>. \u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fassets\u002Fexternal\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002Fassets\u002Fmodule6.png\" alt=\"\">\u003C\u002Fp>\n\u003Ch2>Tools\u003C\u002Fh2>\n\u003Cp>Below tools are used throughout the guide. Install them on your machine if you want to replicate steps described in this guide.\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Fcli\u002Flatest\u002Fuserguide\u002Fgetting-started-install.htm\">AWS CLI\u003C\u002Fa> - installed and configured to work with an AWS Region of your choice\u003C\u002Fli>\n\u003Cli>\u003Ca href=\"https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform\u002Ftutorials\u002Faws-get-started\u002Finstall-cli\">Terraform CLI\u003C\u002Fa>\u003C\u002Fli>\n\u003Cli>Text editor or IDE of your choice, such as \u003Ca href=\"https:\u002F\u002Fcode.visualstudio.com\u002F\">Visual Studio Code\u003C\u002Fa>.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>Let&#39;s get started!\u003C\u002Fp>\n",{"title":6,"order":7,"authors":8,"resources":11},"2. Solution Overview",2,[9,10],"Anton Aleksandrov","Debasis Rath",[12,16,19],{"link":13,"text":14,"type":15},"https:\u002F\u002Fwww.terraform.io\u002F","Hashicorp Terraform","link",{"link":17,"text":18,"type":15},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fcli\u002Flatest\u002Fuserguide\u002Fgetting-started-install.htm","AWS CLI",{"link":20,"text":21,"type":15},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fiam\u002F","AWS IAM","Throughout this guide, you will learn how to use Terraform to build a Serverless application that is used to generate greeting cards for employees working in a fictitious enterprise named AcmeCorp. In the final chapter you can download the sample code used in this guide, as well as get a collection of actionable resources to continue your learning journey. \n\n![](\u002Fassets\u002Fexternal\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002Fassets\u002Fsolution-architecture.png)\n\nEach chapter of this guide builds on the previously created solution, adds a new concept, and explains how to wire it with existing components. Note that this guide is not intended to be consumed as a step-by-step workshop or tutorial, its purpose is to illustrate and provide guidance through the concepts you can use to create your own Serverless applications. \n\n* **Chapter 3** illustrates configuring Terraform and using it to create [Amazon S3](https:\u002F\u002Faws.amazon.com\u002Fs3\u002F) buckets - one for storing employee photos (source bucket), the other for storing generated greeting cards (target bucket).\n* **Chapter 4** shows how to create an [AWS Lambda](https:\u002F\u002Faws.amazon.com\u002Flambda\u002F) function that receives an array of employee IDs and generates greeting cards. The function will retrieve photos from the source bucket, generate greeting cards, and store them in the target bucket. Initially you'll invoke that function manually using the AWS CLI.\n* **Chapter 5** explains how to make the application more consumable by other parts of the business by exposing the functionality via [Amazon API Gateway](https:\u002F\u002Faws.amazon.com\u002Fapi-gateway\u002F).\n* **Chapter 6** introduces additional resiliency and scalability into the architecture by adding an [Amazon SQS](https:\u002F\u002Faws.amazon.com\u002Fsqs\u002F) queue to generate greeting cards asynchronously. This would help during the holiday season, when the app needs to generate greeting cards for thousands of employees.\n* **Chapter 7 and 8** focus on operational aspects of the application, such as observability, deploying to multiple environments and more.\n\n## Identity and Access Management\n\nWhen building applications on AWS, it is important you take care of IAM permissions in order to only allow resources you permit to communicate with each other. For example, you will need to grant your Lambda function permissions to poll (but not push) messages from the SQS queue, as well as read from and write to S3 buckets. \n\nAs a general practice, the guide follows the principle of least privileged access. Each step demonstrates how to grant the minimal required set of permissions. The guide will demonstrate how to use a combination of execution roles and resource policies. For example, the Lambda function will have an execution role allowing it to poll messages from the SQS Queue, and SQS Queue will have a resource policy allowing API Gateway to send messages. Read more about using [AWS IAM](https:\u002F\u002Fdocs.aws.amazon.com\u002Fiam\u002F). \n\n![](\u002Fassets\u002Fexternal\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002Fassets\u002Fmodule6.png)\n\n## Tools\n\nBelow tools are used throughout the guide. Install them on your machine if you want to replicate steps described in this guide.\n\n* [AWS CLI](https:\u002F\u002Fdocs.aws.amazon.com\u002Fcli\u002Flatest\u002Fuserguide\u002Fgetting-started-install.htm) - installed and configured to work with an AWS Region of your choice\n* [Terraform CLI](https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform\u002Ftutorials\u002Faws-get-started\u002Finstall-cli)\n* Text editor or IDE of your choice, such as [Visual Studio Code](https:\u002F\u002Fcode.visualstudio.com\u002F).\n\nLet's get started!\n",[24,25,26,27],"content\u002Fcontributors\u002Fanton-aleksandrov.json","content\u002Fcontributors\u002Fdebasis-rath.json","content\u002Fcontributors\u002Fmatt-ridehalgh.json","content\u002Fcontributors\u002Fluis-cerezo.json","LIST","Building Serverless Applications with Terraform","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F02-solution-overview","3 min",[33],{"title":34,"content":35},"Guide",[36,52,60,76,95,108,123,145,161,176,194],{"title":37,"order":38,"authors":39,"resources":40,"time":48,"path":49,"id":50,"link":51},"1. Introduction",1,[9,10],[41,44,47],{"link":42,"text":43,"type":15},"https:\u002F\u002Faws.amazon.com\u002Fserverless\u002Fsam\u002F","AWS Serverless Application Model (SAM)",{"link":45,"text":46,"type":15},"https:\u002F\u002Faws.amazon.com\u002Fcdk\u002F","AWS Cloud Development Kit (CDK)",{"link":13,"text":14,"type":15},"4 min","01-introduction","01-introduction.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F01-introduction",{"title":6,"order":7,"authors":53,"resources":54,"time":31,"path":58,"id":59,"link":30},[9,10],[55,56,57],{"link":13,"text":14,"type":15},{"link":17,"text":18,"type":15},{"link":20,"text":21,"type":15},"02-solution-overview","02-solution-overview.md",{"title":61,"order":62,"authors":63,"resources":65,"time":48,"path":73,"id":74,"link":75},"3. S3 buckets",3,[9,10,64],"Matt Ridehalgh",[66,70],{"link":67,"text":68,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs","AWS Terraform Provider","Documentation",{"link":71,"text":72,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fs3_bucket","aws_s3_bucket","03-s3-buckets","03-s3-buckets.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F03-s3-buckets",{"title":77,"order":78,"authors":79,"resources":80,"time":48,"path":92,"id":93,"link":94},"4. Lambda functions",4,[9,10],[81,82,85,88],{"link":67,"text":68,"type":69},{"link":83,"text":84,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Flambda_function","aws_lambda_function",{"link":86,"text":87,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fserverless-application-model\u002Flatest\u002Fdeveloperguide\u002Fterraform-support.html","AWS SAM Terraform support",{"link":89,"text":90,"type":91},"https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fbuilding-serverless-applications-with-terraform\u002Fblob\u002Fmain\u002Flambdas\u002Fgreetings_lambda\u002Findex.mjs","index.mjs","Sample","04-lambda-functions","04-lambda-functions.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F04-lambda-functions",{"title":96,"order":97,"authors":98,"resources":99,"time":48,"path":105,"id":106,"link":107},"5. API Gateway",5,[9,10],[100,101,104],{"link":67,"text":68,"type":69},{"link":102,"text":103,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fapi_gateway_rest_api","aws_api_gateway_rest_api",{"link":86,"text":87,"type":69},"05-api-gateway","05-api-gateway.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F05-api-gateway",{"title":109,"order":110,"authors":111,"resources":112,"time":48,"path":120,"id":121,"link":122},"6. Asynchronous processing",6,[9,10],[113,114,117],{"link":67,"text":68,"type":69},{"link":115,"text":116,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fsqs_queue","aws_sqs_queue",{"link":118,"text":119,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Flambda_event_source_mapping","aws_lambda_event_source_mapping","06-async-processing","06-async-processing.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F06-async-processing",{"title":124,"order":125,"authors":126,"resources":127,"time":141,"path":142,"id":143,"link":144},"7. Observability",7,[9,10],[128,129,132,135,138],{"link":67,"text":68,"type":69},{"link":130,"text":131,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Flambda-monitoring.html","Lambda function observability, monitoring, and troubleshooting",{"linke":133,"text":134,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fapigateway\u002Flatest\u002Fdeveloperguide\u002Frest-api-monitor.html","Monitoring API Gateway REST API",{"link":136,"text":137,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fapi_gateway_account","aws_api_gateway_account",{"link":139,"text":140,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fapi_gateway_stage","aws_api_gateway_stage","5 min","07-observability","07-observability.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F07-observability",{"title":146,"order":147,"authors":148,"resources":149,"time":157,"path":158,"id":159,"link":160},"8. Modularizing your IaC projects",8,[9,10],[150,151,154],{"link":67,"text":68,"type":69},{"link":152,"text":153,"type":69},"https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform\u002Flanguage\u002Fmodules","Terraform Modules",{"link":155,"text":156,"type":91},"https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fbuilding-serverless-applications-with-terraform","Sample project source code","8 min","08-modularizing-your-iac-projects","08-modularizing-your-iac-projects.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F08-modularizing-your-iac-projects",{"title":162,"order":163,"authors":164,"resources":165,"time":172,"path":173,"id":174,"link":175},"9. Summary and next steps",9,[9,10],[166,167,169,171],{"link":67,"text":68,"type":69},{"link":168,"text":14,"type":69},"https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform",{"link":42,"text":170,"type":69},"AWS SAM",{"link":155,"text":156,"type":91},"2 min","09-summary","09-summary.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F09-summary",{"title":177,"order":178,"authors":179,"resources":181,"time":141,"path":191,"id":192,"link":193},"10. Appendix A - Amazon EventBridge",10,[9,10,180],"Luis Cerezo",[182,185,188],{"link":183,"text":184,"type":69},"https:\u002F\u002Fregistry.terraform.io\u002Fproviders\u002Fhashicorp\u002Faws\u002Flatest\u002Fdocs\u002Fresources\u002Fcloudwatch_event_bus","aws_cloudwatch_event_bus Terraform resource",{"link":186,"text":187,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fhealth\u002Flatest\u002Fug\u002Fcloudwatch-events-health.html","Monitoring AWS Health events with Amazon EventBridge",{"link":189,"text":190,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fhealth\u002Flatest\u002Fug\u002Faws-health-planned-lifecycle-events.html#planned-lifecycle-event-notifications","Planned lifecycle events for AWS Health - What should I expect when I receive a planned lifecycle event notification?","10-appendix-A-EventBridge","10-appendix-A-EventBridge.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F10-appendix-A-EventBridge",{"title":195,"order":196,"authors":197,"resources":198,"time":48,"path":207,"id":208,"link":209},"10. Appendix B - AWS Step Functions",11,[9,10,180],[199,202,204],{"link":200,"text":201,"type":69},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fdevops\u002Fbest-practices-for-writing-step-functions-terraform-projects\u002F","Best Practices for Writing Step Functions Terraform Projects",{"link":183,"text":203,"type":69},"cloudwatch_event_bus terraform resource",{"link":205,"text":206,"type":69},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fstep-functions\u002Flatest\u002Fdg\u002Fconcepts-amazon-states-language.html","Amazon States Language","10-appendix-B-SFN","10-appendix-B-SFN.md","\u002Fcontent\u002Fguides\u002Fbuilding-serverless-applications-with-terraform\u002F10-appendix-B-SFN",1792665264301]