mirror of
https://gitlab.sarex.io/infra/terraform-contour-mirror.git
synced 2026-08-06 18:51:36 +03:00
- Add modules: yc-s3, yc-postgresql, k8s-namespace, k8s-secrets - Add live configuration for stage environment - Add GitLab CI with downstream pipelines - Implement best practices from theory.md
45 lines
1.6 KiB
HCL
45 lines
1.6 KiB
HCL
# Создание сервисного аккаунта для S3
|
||
resource "yandex_iam_service_account" "sa" {
|
||
name = "${var.bucket_name}-sa"
|
||
description = "Service account for ${var.bucket_name} bucket"
|
||
}
|
||
|
||
# Назначение роли storage.editor сервисному аккаунту
|
||
resource "yandex_resourcemanager_folder_iam_member" "storage_editor" {
|
||
folder_id = var.folder_id
|
||
role = "storage.editor"
|
||
member = "serviceAccount:${yandex_iam_service_account.sa.id}"
|
||
}
|
||
|
||
# Создание статического ключа доступа
|
||
resource "yandex_iam_service_account_static_access_key" "sa_key" {
|
||
service_account_id = yandex_iam_service_account.sa.id
|
||
description = "Static access key for ${var.bucket_name} bucket"
|
||
}
|
||
|
||
# Создание S3 бакета с публичным доступом
|
||
resource "yandex_storage_bucket" "pulse" {
|
||
bucket = var.bucket_name
|
||
access_key = yandex_iam_service_account_static_access_key.sa_key.access_key
|
||
secret_key = yandex_iam_service_account_static_access_key.sa_key.secret_key
|
||
|
||
# Публичный доступ для чтения
|
||
acl = "public-read"
|
||
|
||
# Настройка CORS для внешнего доступа
|
||
cors {
|
||
allowed_headers = ["*"]
|
||
allowed_methods = ["GET", "PUT", "POST", "DELETE", "HEAD"]
|
||
allowed_origins = ["*"]
|
||
expose_headers = ["ETag"]
|
||
max_age_seconds = 3600
|
||
}
|
||
|
||
# Версионирование объектов
|
||
versioning {
|
||
enabled = var.versioning_enabled
|
||
}
|
||
|
||
depends_on = [yandex_resourcemanager_folder_iam_member.storage_editor]
|
||
}
|