majuna/app/terraform/list/s3.py

39 lines
929 B
Python
Raw Normal View History

2022-03-10 14:26:22 +00:00
from app.terraform.list import ListAutomation
class ListS3Automation(ListAutomation):
2022-03-10 14:26:22 +00:00
short_name = "list_s3"
description = "Update mirror lists in AWS S3 buckets"
2022-03-10 14:26:22 +00:00
provider = "s3"
template_parameters = [
"aws_access_key",
"aws_secret_key"
]
template = """
terraform {
required_providers {
aws = {
version = "~> 4.4.0"
}
}
}
provider "aws" {
access_key = "{{ aws_access_key }}"
secret_key = "{{ aws_secret_key }}"
region = "us-east-1"
}
{% for list in lists %}
resource "aws_s3_object" "object_{{ list.id }}" {
bucket = "{{ list.container }}"
key = "{{ list.filename }}"
source = "{{ list.format }}.json"
content_type = "application/json"
etag = filemd5("{{ list.format }}.json")
}
{% endfor %}
"""