feat: moved gitea terraform to this repository
This commit is contained in:
31
terraform/iam.tf
Normal file
31
terraform/iam.tf
Normal file
@@ -0,0 +1,31 @@
|
||||
data "aws_s3_bucket" "storage_bucket" {
|
||||
bucket = var.gitea_boot.bucket
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "gitea_bool_policy" {
|
||||
statement {
|
||||
effect = "Allow"
|
||||
actions = ["s3:*", "s3-object-lambda:*"]
|
||||
resources = ["${data.aws_s3_bucket.storage_bucket.arn}/${var.gitea_boot.key}"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_iam_policy" "gitea_boot_policy" {
|
||||
name = "${var.gitea_boot.role}Policy"
|
||||
description = "The policy that manages the Gitea Boot."
|
||||
|
||||
policy = data.aws_iam_policy_document.gitea_bool_policy.json
|
||||
}
|
||||
|
||||
resource "aws_iam_user" "gitea_boot_user" {
|
||||
name = "${var.gitea_boot.role}User"
|
||||
}
|
||||
|
||||
resource "aws_iam_user_policy_attachment" "attachment" {
|
||||
user = aws_iam_user.gitea_boot_user.name
|
||||
policy_arn = aws_iam_policy.gitea_boot_policy.arn
|
||||
}
|
||||
|
||||
resource "aws_iam_access_key" "gitea_boot_key" {
|
||||
user = aws_iam_user.gitea_boot_user.name
|
||||
}
|
||||
25
terraform/main.tf
Normal file
25
terraform/main.tf
Normal file
@@ -0,0 +1,25 @@
|
||||
data "aws_iam_instance_profile" "ssm" {
|
||||
name = "SSMInstanceProfile"
|
||||
}
|
||||
|
||||
# The Gitea instance.
|
||||
resource "aws_instance" "gitea" {
|
||||
# ami = data.aws_ami.amazon-linux-2.id
|
||||
ami = "ami-0adec96dc0cdc7bca"
|
||||
instance_type = "t4g.nano"
|
||||
subnet_id = module.vpc.private_subnets[0]
|
||||
|
||||
user_data = file("install.sh")
|
||||
user_data_replace_on_change = true
|
||||
|
||||
iam_instance_profile = data.aws_iam_instance_profile.ssm.name
|
||||
|
||||
root_block_device {
|
||||
volume_type = "gp3"
|
||||
volume_size = 8
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "Codebase: Gitea"
|
||||
}
|
||||
}
|
||||
27
terraform/output.tf
Normal file
27
terraform/output.tf
Normal file
@@ -0,0 +1,27 @@
|
||||
output "instance_id" {
|
||||
value = aws_instance.gitea.id
|
||||
description = "The instance ID of the Gitea instance."
|
||||
}
|
||||
|
||||
output "ip_address" {
|
||||
value = aws_instance.gitea.private_ip
|
||||
description = "The Gitea IP address."
|
||||
}
|
||||
|
||||
output "boot_region" {
|
||||
value = var.region
|
||||
description = "The region to manipulate the codebase repository boot."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "boot_id" {
|
||||
value = aws_iam_access_key.gitea_boot_key.id
|
||||
description = "The access id to manipulate the codebase repository boot."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "boot_secret" {
|
||||
value = aws_iam_access_key.gitea_boot_key.secret
|
||||
description = "The access secret to manipulate the codebase repository boot."
|
||||
sensitive = true
|
||||
}
|
||||
13
terraform/variables.tf
Normal file
13
terraform/variables.tf
Normal file
@@ -0,0 +1,13 @@
|
||||
variable "region" {
|
||||
type = string
|
||||
description = "The AWS region things are created in."
|
||||
}
|
||||
|
||||
variable "gitea_boot" {
|
||||
type = object({
|
||||
bucket = string
|
||||
key = string
|
||||
role = string
|
||||
})
|
||||
description = "The storage for the Gitea instance."
|
||||
}
|
||||
Reference in New Issue
Block a user