Skip to content

Commit

Permalink
Add IAM resources for GitHub Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertClo committed Aug 7, 2024
1 parent 80da2b6 commit 68a9f1d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions infra/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ resource "aws_key_pair" "albert_ssh_key" {
})
}

# Generates an IAM user and access key for GitHub Actions
resource "aws_iam_user" "albertclo_github_actions_user" {
name = "albertclo-github-actions"

tags = merge(local.common_tags, {
Name = "albertclo-github-actions"
})
}

# Creates an access key for the GitHub Actions user
resource "aws_iam_access_key" "albertclo_github_actions_access_key" {
user = aws_iam_user.albertclo_github_actions_user.name
}

# Creates a security group to control inbound and outbound traffic
resource "aws_security_group" "albertclo_com_sec_group" {
name = "albertclo_com_sec_group"
Expand Down Expand Up @@ -376,8 +390,27 @@ output "instance_public_ip" {
value = aws_instance.albertclo_com.public_ip
}

# Outputs the AlbertClo EC2 instance ID
output "instance_id" {
description = "ID of the EC2 instance"
value = aws_instance.albertclo_com.id
}

# Outputs the public key for GitHub deployment
output "github_public_key" {
description = "GitHub deploy key"
value = tls_private_key.albertclo_github_deploy_key.public_key_openssh
}

# Outputs the access key for GitHub Actions
output "github_actions_access_key" {
description = "Access key for GitHub Actions"
value = aws_iam_access_key.albertclo_github_actions_access_key.id
}

# Outputs the secret key for GitHub Actions
output "github_actions_secret_key" {
description = "Secret key for GitHub Actions"
value = aws_iam_access_key.albertclo_github_actions_access_key.secret
}

0 comments on commit 68a9f1d

Please sign in to comment.