AWS_AMI_MAPS.j 962 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {% import 'variables.include' as var %}
  2. #############
  3. # Search for AMIs for your OS Preference
  4. data "aws_ami" "ubuntu" {
  5. most_recent = true
  6. filter {
  7. name = "name"
  8. values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
  9. }
  10. filter {
  11. name = "virtualization-type"
  12. values = ["hvm"]
  13. }
  14. owners = ["099720109477"] # Canonical
  15. }
  16. # Use via: ami = "${data.aws_ami.ubuntu.id}"
  17. data "aws_ami" "centos6" {
  18. most_recent = true
  19. owners = ["679593333241"]
  20. filter {
  21. name = "name"
  22. values = ["CentOS Linux 6 x86_64 HVM EBS *"]
  23. }
  24. }
  25. data "aws_ami" "centos7" {
  26. most_recent = true
  27. owners = ["679593333241"]
  28. filter {
  29. name = "name"
  30. values = ["CentOS Linux 7 x86_64 HVM EBS *"]
  31. }
  32. }
  33. #############
  34. # Old fashioned method, manual mapping:
  35. variable "ubuntu_amis" {
  36. type = map
  37. default = {
  38. us-east-1 = "ami-40d28157"
  39. us-east-2 = "ami-153e6470"
  40. }
  41. }
  42. # Use with: ami = "${lookup(var.ubuntu_amis, var.region)}"