This article provides a step-by-step guide for deploying AWS SNS and Lambda using Terraform, while also detailing the issues encountered and how to fix them.
The first step is initializing Terraform in your project directory using the 'terraform init' command.
Next, the author ran 'terraform fmt' and 'terraform validate' to ensure consistent formatting and validate syntax correctness.
After running 'terraform plan' and reviewing it, the author then executed 'terraform apply' to provision resources and deployed the infrastructure.
The author encountered errors while creating an IAM role for Lambda and discovered that it was due to lacking the necessary permissions to create roles.
The author added the necessary permissions, ran 'terraform apply' again, and the role was created successfully.
Another error was encountered during the Lambda function deployment, which resulted in incorrect ZIP file creation. The author learned that it is important to verify package contents before deployment.
The author created the ZIP file with the necessary contents and dependencies, ran 'terraform apply', and the Lambda function was deployed correctly.
After the successful creation of Lambda and SNS, the author added subscriptions and tested them by verifying the expected notifications were received.
Proper cleanup is crucial, which is why the author details a cleanup process for Terraform that removes all AWS resources in the correct order.