AWS_AMI_MAPS.j 631 B

1234567891011121314151617181920212223242526272829
  1. {% import 'variables.include' as var %}
  2. #############
  3. # New method: Search for it!
  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. #############
  18. # Old fashioned method, manual mapping:
  19. variable "ubuntu_amis" {
  20. type = "map"
  21. default = {
  22. us-east-1 = "ami-40d28157"
  23. us-east-2 = "ami-153e6470"
  24. }
  25. }
  26. # Use with: ami = "${lookup(var.ubuntu_amis, var.region)}"