Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mgmt #2

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions environments/mgmt/development-terminal/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@ dependency "network" {
mock_outputs_merge_strategy_with_state = "shallow"
mock_outputs = {
vpc_id = "vpc-000000000000000"
public_subnets = ["subnet-eeeeeeeeeeeeeeeee"]
private_subnets = ["subnet-eeeeeeeeeeeeeeeee"]
}
}
# 依存関係のテスト用
dependency "nat_instance" {
config_path = "../nat-instance"

mock_outputs_merge_strategy_with_state = "shallow"
mock_outputs = {
nat_instance_sg_id = "sg-1xxxxxxxxxxxxxxxx"
}

}
inputs = {
vpc_id = dependency.network.outputs.vpc_id
public_subnets = dependency.network.outputs.public_subnets
private_subnets = dependency.network.outputs.private_subnets
}
4 changes: 2 additions & 2 deletions environments/mgmt/development-terminal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ variable "vpc_id" {
type = string

}
variable "public_subnets" {
description = "Public Subnets"
variable "private_subnets" {
description = "Private Subnets"
type = list(string)
}

9 changes: 5 additions & 4 deletions modules/development-terminal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ resource "aws_vpc_security_group_ingress_rule" "main" {
to_port = each.value.to_port
}
data "aws_ssm_parameter" "ubuntu" {
name = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-arm64"
name = "/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id"
}


## ec2 role
data "aws_iam_policy_document" "main" {
statement {
Expand Down Expand Up @@ -62,12 +63,12 @@ resource "aws_iam_instance_profile" "main" {
}

resource "aws_instance" "main" {
ami = var.ec2_instance_info.ami
ami = data.aws_ssm_parameter.ubuntu.value
instance_type = var.ec2_instance_info.instance_type
subnet_id = var.ec2_instance_info.subnet_id
vpc_security_group_ids = [aws_security_group.main.id]
associate_public_ip_address = true
user_data = templatefile("${path.module}/templates/user_data.sh.tftpl", {})
associate_public_ip_address = false
user_data = file("${path.module}/templates/user_data.sh.tftpl")
key_name = var.ec2_instance_info.key_pair_name
iam_instance_profile = aws_iam_instance_profile.main.name
# user_dataの変更があった場合にインスタンスを再作成するかどうか。falseにすると変更があっても停止・起動の動作となる
Expand Down
1 change: 0 additions & 1 deletion modules/development-terminal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ variable "vpc_id" {
}
variable "ec2_instance_info" {
type = object({
ami = string
instance_type = string
subnet_id = string
key_pair_name = string
Expand Down
Loading