![]() All the resources needed to run our function are provisioned and brought online in response to certain events. If you are unsure what AWS Lambda is you should take a quick peek at this article, but basically Lambdas are nothing more that a function, that we define, which is executed on demand by the AWS infrastructure. Of course we cannot really do much with what we have, aside from having looked at Terraform but we have a base to build the next piece of our infrastructure. LambdaĪt this point we have a very simple Message Broker using AWS resources. This is great, in the AWS console we see exactly all the things we have created, just like we had planned. If you look closely at the screenshot below you will see the details of the queue and under the permissions tab you can see that the queue is subscribed to the results-updates-topic. Once you do that you can navigate to Simple Queue System and view the Queue and its contents. Insert a title and a message body and if you scroll down you will find the Publish Message button. You can test your infrastructure simply by clicking on Publish Message and you will be able to send a test message. And as you can see from the screenshot below, the subscription points to an SQS queue. If you click on the Topic you just created you will be able to see its details, including the Subscription details. If we log in to our AWS console and select Simple Notification Service from the Services menu we will be presented with the Topics Dashboard.įrom the Dashboard if you click on the number under Topics, you will be taken to the Topic list page. $ terraform apply -var-file = "vars.tfvars" AWSĪt this point, if you followed all the steps above and ran Terraform, you will have a new SNS topic and an SQS queue subscribed to the SNS topic. The command is safe to run multiple times. You should run this command the first time you create a new Terraform configuration or when you make substantial changes and include new providers. The command is used to initialize your working directory containing the configuration files. Initializeįirst lets initialize Terraform using the init command. ![]() When you run Terraform you will need to go through the following commands. Now you could easily run Terraform and provision your infrastructure. Resource "aws_sqs_queue_policy" "results_updates_queue_policy" "Īt this point we have everything which is in the original CDK tutorial I worked through. Providerįirst of all we will just create the needed files in a new directory, and of course you are free to modify names and structure as you see fit. So, after all the introductions lets finally see some code. For those of you using a mac, you can simply use Homebrew. If you don’t have Terraform installed I suggest you take a look at the official installation documentation, which will guide you through the installation process based on the OS you are using. For an in depth introduction to Terraform you should take a look at this post on Hackernoon Installation Terraform comes with lots of built in providers as well and community maintained ones. Each provider specifies Resources and Data sources which allow you to provision your infrastructure. Terraform consists of language constructs that allow you to address different platforms using Providers. The great thing about Terraform is that it is not locked into one specific vendor, meaning that you can use it to provision AWS infrastructure, as well as Azure or even Digital Ocean and lots more. Terraform was created by HashiCorp and is a tool to help provision infrastructure as code. If you are already familiar with Terraform feel free to skip over to the next section. I thought that it would be really cool to see if I could reproduce the output from the AWS CDK tutorial, but just using Terraform. ![]() This is why I decided to write this post. I wish there were more real life examples out there, even though the documentation is great more tutorial would be even better. I personally like Terraform, I don’t think it a perfect tool, but I like it a lot. But of course I do have my preferences, some make sense, other less so… Be it Python or Node or Java or something completely different. At the end you were left with a simple yet powerful infrastructure in AWS that consisted of an SNS Topic, an SQS queue with a subscription, and a Lambda function that consumed the SQS queue.įor anyone that knows me personally, you know that I am not a fanatic when it comes to programming languages or tools for the job, my philosophy is and has always been to try and use the best tools for the job. The tutorial was great, easy to go through and very interesting. I honestly had never worked with the CDK, so I decided to start like the newbie I was and dig into a tutorial recommended by a colleague. Recently I worked with the AWS CDK to provision a certain amount of infrastructure for a project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |