Deploying an AWS instance from Marketplace images using Terraform

In a previous post we looked at network requirements required to deploy an instance in AWS. In this post we are going to look at what it takes to pull a Marketplace Amazon Machine Instance (AMI) from the marketplace and deploy it into a virtual private cloud with the appropriate network security group and subnet definitions.

If you go into the AWS Marketplace from the AWS Console you get a list of virtual machine images. We are going to deploy a Commvault CommServe server instance because it is relatively complex with networking requirements, SQL Server, IIS Server, and customization after the image is deployed. We could just as easily have done a Windows 2016 Server or Ubuntu 18 Server instance but wanted to do something a little more complex.

The Cloud Control is a Windows CommServe server installation. The first step needed is to open a PowerShell and connect to Amazon using the aws command line interface. This might require an Install-Module aws to get the aws command line installed and configured but once it is ready to connect to aws by typing in

aws configure

We can search for Marketplace images by doing an ec2 describe-images with a filter option

aws ec2 describe-images –executable-users all –filters “Name=name,Values=*Cloud Control*”

The describe-images command searches for an Amazon AMI that matches the description that we are looking for and returns an AMI ID. From this we can create a new instance pre-configured with a CommServe server. From here we can create out terraform files. It is important to note that the previous examples of main.tf and network.tf files do not need to be changed for this definition. We only need to create a virtual_machine.tf file to define our instance and have it created with the network configurations that we have previously defined.

We will need to create a new variable in our main.tf file that defines the private and public key that we are going to use to authenticate against our Windows server.

resource “aws_key_pair” “cmvlt2020” {
provider = aws.east
key_name = “cmvlt2020”
public_key = “AAAAB3NzaC1yc2EAAAADAQABAAABAQCtVZ7lZfbH8ZKC72A+ipNB6L/upQrj8pRxLwzQi7LVPrameil8/q4ROvWbC1KC9A3Ego”
}

A second element that needs to be defined is an aws_ami data declaration to reference an existing AMI. This can be done in the virtual_machines.tf file to isolate the variable and data declaration for virtual machine specific definitions. If we wanted to define an Ubuntu instance we would need to define the owner as well as the filter to use for an aws_ami search. In this example we are going to look for Ubuntu on an AMD 64-bit processor. The unusualness is the owners that needs to be used for Ubuntu since it is controlled by a third part Marketplace owner.

variable “ubuntu-version” {
type = string
default = “bionic”
# default = “xenial”
# default = “groovy”
# default = “focal”
# default = “trusty”
}

data “aws_ami” “ubuntu” {
provider = aws.east
most_recent = true
# owners = [“Canonical”]
owners = [“099720109477”]
filter {
name = “name”
values = [“ubuntu/images/hvm-ssd/ubuntu-${var.ubuntu-version}–amd64-server-“]
}
}

output “Ubuntu_image_name” {
value = “${data.aws_ami.ubuntu.name}”
}

output “Ubuntu_image_id” {
value = “${data.aws_ami.ubuntu.id}”
}

In this example we will be pulling the ubuntu-bionic-amd64-server image that has hardware virtualization running on a solid state disk. The variable ubuntu-version is mapped to the version of the Ubuntu kernel that is desired. The filter.values does the search in the Marketplace store to find the AMI ID. We restrict the search by searching in the region that we are deploying and use owner “099720109477” as the Marketplace provider.

If we compare this to a CentOS deployment the centos-version variable has a different string definition and a different owner.

variable “centos-version” {
type = string
default = “Linux 7 x86_64”
# default = “Linux 6 x86_64”
}

data “aws_ami” “centos” {
provider = aws.east
most_recent = true
owners = [“aws-marketplace”]

filter {
name = “name”
values = [“CentOS ${var.centos-version}*”]
}
}

output “CentOS_image_name” {
value = “${data.aws_ami.centos.name}”
}

output “CentOS_image_id” {
value = “${data.aws_ami.centos.id}”
}

For CentOS we can deploy 6 or version 7 by changing the centos-version.default definition. It is important to note that the owner of this AMI is not Amazon and uses the aws-marketplace definition to perform the filter. The same is true for the Commvault image that we are looking at.

data “aws_ami” “commvault” {
provider = aws.east
most_recent = true
# owners = [“Canonical”]
owners = [“aws-marketplace”]

filter {
name = “name”
values = [“*Cloud Control*”]
}
}

output “Commvault_CommServe_image_name” {
value = “${data.aws_ami.commvault.name}”
}

output “Commvault_CommServe_image_id” {
value = “${data.aws_ami.amazon.id}”
}

Note the filter uses a leading wildcard with the name “Cloud Control” followed by a wildcard to look for the instance that we are looking for. Once we have the AMI we can use the AMI.id from our search to define the aws_instance definition.

resource “aws_instance” “commserve” {
provider = aws.east
ami = data.aws_ami.commvault.id
associate_public_ip_address = true
instance_type = “m5.xlarge”
key_name = “cmvlt2020”
vpc_security_group_ids = [aws_security_group.cmvltRules.id]
subnet_id = aws_subnet.mySubnet.id
tags = {
Name = “TechEnablement test”
environment = var.environment
createdby = var.createdby
}
}

output “test_instance” {
value = aws_instance.commserve.public_ip
}

If we take the aws_instance declaration piece by piece the provider defines which AWS region that we will provision into Amazon. The vpc_security_group_ids and subnet_id defines what network that this instance will join. The new declarations are

  • ami – AWS AMI id to use as the source to clone
  • associate_public_ip_address – do we want a public or private only IP address with this instance
  • instance_type – this is the size. We need to reference the documentation or our users to figure out how large or how small this server needs to be. From the Commvault documentation the smallest recommended size is an m5.xlarge.
  • key_name – this is the public and private key names that will be used to connect to the Windows instance.

The remainder of the variables like disk, is this a Windows instance, and all the regular required parameters we saw with a vsphere_virtual_machine are provided by the AMI definition.

With these files we can execute from the following files

  • aws configure
  • terraform init
  • terraform plan
  • terraform apply

In summary, pulling an AMI ID from the marketplace works well and allows us to dynamically create virtual machines from current or previous builds. The terraform apply finishes quickly but the actual spin up of the Windows instance takes a little longer. Using Marketplace instances like the Commvault AMI provides a good foundation for a proof of concept or demo platform. The files used in this example are available in github.com.

101 thoughts on “Deploying an AWS instance from Marketplace images using Terraform”

  1. Thanks for sharing your ideas listed here. The other thing is that each time a problem comes up with a laptop motherboard, individuals should not take the risk with repairing the item themselves because if it is not done properly it can lead to permanent damage to all the laptop. Most commonly it is safe to approach any dealer of your laptop for the repair of its motherboard. They’ve already technicians who have an knowledge in dealing with laptop motherboard problems and can make the right prognosis and undertake repairs.

  2. Yesterday, while I was at work, my sister stole my apple ipad and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!

  3. you’re really a good webmaster. The website loading speed is incredible. It seems that you are doing any unique trick. Furthermore, The contents are masterpiece. you’ve done a magnificent job on this topic!

  4. hello there and thank you for your info ?I have definitely picked up anything new from right here. I did then again experience a few technical issues using this web site, since I skilled to reload the website lots of occasions previous to I may get it to load properly. I had been pondering in case your web host is OK? No longer that I am complaining, but sluggish loading cases occasions will sometimes affect your placement in google and could injury your quality ranking if advertising and ***********|advertising|advertising|advertising and *********** with Adwords. Well I am adding this RSS to my e-mail and can look out for a lot more of your respective interesting content. Ensure that you replace this once more soon..

  5. Hello there, I found your site via Google at the same time as searching for a related topic, your web site came up, it appears to be like good. I have bookmarked it in my google bookmarks.

  6. The things i have generally told people is that when looking for a good online electronics store, there are a few variables that you have to remember to consider. First and foremost, you need to make sure to find a reputable and also reliable store that has obtained great testimonials and rankings from other customers and business sector analysts. This will make certain you are getting through with a well-known store that can offer good assistance and aid to it’s patrons. Many thanks sharing your notions on this site.

  7. Здравствуйте друзья!

    Есть такой замечательный сайт https://ruposters.ru/

    Из последних новостей шоу бизнеса узнал, что:Знаменитости из России Лобода и Константин Меладзе поселились в Латвии, а детей пристроили в элитные школы.

    А певец Николай Басков впервые высказался по политической теме, осудив бежавших звезд из России.

    Рэпер Тимати посетил военный госпиталь, и привез около полусотни средств реабилитации для раненных военнослужащих, чтобы те быстрее возвращались к обычной жизни.

    Увидимся!

  8. I am commenting to make you know what a notable encounter my girl had going through your web site. She mastered many issues, including what it’s like to have an incredible coaching nature to let many more without hassle understand a variety of extremely tough subject matter. You actually exceeded people’s desires. Thank you for rendering such informative, trusted, revealing and even fun tips on the topic to Lizeth.

  9. Thanks for all your hard work on this web page. Kate take interest in doing internet research and it’s really obvious why. We all hear all concerning the compelling ways you create useful secrets by means of the web blog and welcome contribution from visitors on that theme then our own girl is now becoming educated a lot. Have fun with the remaining portion of the new year. You’re carrying out a glorious job.

  10. I intended to draft you that tiny word so as to thank you very much again for your wonderful methods you’ve discussed in this article. It’s certainly generous with people like you to convey publicly all many people could possibly have marketed as an e-book in making some money for themselves, mostly considering the fact that you could have done it in case you desired. The techniques likewise acted to be a great way to know that many people have a similar desire like my personal own to figure out much more in terms of this condition. I am certain there are numerous more pleasurable opportunities ahead for many who find out your site.

  11. Приветствую Вас дамы и господа!
    Есть такой интересный сайт https://dengi-do-zarplaty.ru/
    Чтобы оформить деньги в долг, вам не нужен специальный пакет документов, достаточно только паспорта. Это выгодно отличает микрофинансовые компании от банков в, которые требуют собрать несколько бумаг, на подготовку которых уходит пара дней.В заключение стоит сказать, что взять средства в МФО — простой и быстрый способ решения денежных проблем. Компании предоставляют множество заемных линий для людей с разными возможностями, поэтому вы обязательно найдете подходящий вариант. Главное — грамотно распорядиться займом и не тратить деньги на ненужные вещи.

  12. I must show appreciation to the writer for rescuing me from such a setting. Right after surfing around throughout the the web and getting ways which are not powerful, I believed my entire life was well over. Living minus the solutions to the difficulties you’ve fixed by way of your main site is a critical case, as well as ones that might have in a negative way damaged my entire career if I had not encountered your blog post. Your main talents and kindness in playing with all the stuff was very helpful. I am not sure what I would’ve done if I had not come upon such a thing like this. I can also at this point relish my future. Thanks so much for the high quality and effective help. I won’t be reluctant to endorse the blog to anybody who should get guidelines about this problem.

  13. Thanks a lot for providing individuals with a very marvellous possiblity to read articles and blog posts from this site. It is always so brilliant plus packed with fun for me and my office colleagues to search the blog at the least three times every week to read through the latest items you have got. Not to mention, we are always satisfied with your astonishing opinions served by you. Some 4 ideas in this posting are undeniably the most efficient I’ve had.

  14. Thank you for each of your work on this web page. My aunt delights in doing research and it’s simple to grasp why. All of us notice all about the lively means you produce very important suggestions through this web site and therefore foster participation from the others about this subject while our own princess has always been learning a lot of things. Enjoy the remaining portion of the year. You are always conducting a terrific job.

  15. I not to mention my buddies appeared to be digesting the nice tactics located on your site while suddenly I had a terrible suspicion I never expressed respect to you for those strategies. The people became as a result very interested to learn them and have in effect extremely been having fun with them. Thanks for really being well thoughtful and then for settling on this sort of remarkable areas most people are really wanting to learn about. My personal honest regret for not expressing gratitude to earlier.

  16. I am also commenting to let you understand of the impressive experience my wife’s child went through studying your site. She mastered a lot of details, with the inclusion of what it is like to have an incredible teaching style to make the rest with ease have an understanding of specified multifaceted things. You undoubtedly did more than people’s expectations. Many thanks for rendering the helpful, safe, explanatory and also cool guidance on the topic to Mary.

  17. I intended to put you that little bit of word so as to thank you so much the moment again regarding the lovely tactics you have provided in this article. It has been simply incredibly open-handed with you to deliver easily precisely what a few people would have offered as an e book to earn some cash on their own, particularly since you might well have tried it in case you decided. Those points likewise acted to be a fantastic way to realize that other people have the same dreams just as my personal own to realize more and more pertaining to this problem. I believe there are several more pleasant sessions ahead for those who read carefully your blog post.

  18. I truly wanted to write a comment to be able to thank you for those fantastic facts you are giving at this site. My time-consuming internet search has at the end been recognized with incredibly good details to write about with my company. I ‘d admit that most of us visitors are quite endowed to be in a magnificent website with many marvellous professionals with good guidelines. I feel really happy to have encountered your web page and look forward to tons of more pleasurable times reading here. Thanks a lot again for all the details.

  19. I and also my friends have already been digesting the nice information on the website and so all of a sudden got an awful feeling I never expressed respect to you for those secrets. My women appeared to be as a consequence very interested to study all of them and already have quite simply been enjoying them. Appreciation for genuinely well kind and then for obtaining this form of incredibly good topics most people are really desperate to be informed on. My personal sincere apologies for not saying thanks to sooner.

  20. My husband and i got more than happy when Edward managed to round up his research through your ideas he received through the weblog. It is now and again perplexing just to possibly be making a gift of concepts that many people might have been selling. And now we already know we’ve got the blog owner to be grateful to because of that. The entire explanations you have made, the easy web site menu, the relationships you make it easier to create – it is many exceptional, and it is helping our son in addition to the family do think that matter is brilliant, which is certainly truly important. Thank you for all!

  21. I am also commenting to make you understand of the fantastic experience my princess undergone viewing your webblog. She mastered such a lot of things, not to mention how it is like to have a wonderful helping heart to let other individuals effortlessly gain knowledge of a number of problematic things. You really exceeded visitors’ expectations. I appreciate you for showing the necessary, trusted, educational and even unique thoughts on the topic to Jane.

  22. I actually wanted to write down a brief note so as to say thanks to you for those superb concepts you are sharing at this website. My particularly long internet look up has finally been rewarded with reputable know-how to go over with my classmates and friends. I would claim that most of us visitors are unquestionably blessed to live in a remarkable place with so many marvellous individuals with useful principles. I feel truly happy to have seen your site and look forward to many more awesome minutes reading here. Thanks a lot once again for a lot of things.

Leave a Reply

Your email address will not be published. Required fields are marked *