diff --git a/lab-3/README.md b/lab-3/README.md index e32ed76..94f6fa7 100644 --- a/lab-3/README.md +++ b/lab-3/README.md @@ -177,6 +177,7 @@ resource "aws_instance" "my_second_linux" { instance_type = "t2.micro" ami = aws_ami_from_instance.ami_snapshot.arn security_groups = ["ssh-access-witch"] + iam_instance_profile = aws_iam_instance_profile.daphodell_profile.name tags = { Name = "labs" diff --git a/lab-3/terraform/main.tf b/terraform/main.tf similarity index 89% rename from lab-3/terraform/main.tf rename to terraform/main.tf index 4e58df6..25844ac 100644 --- a/lab-3/terraform/main.tf +++ b/terraform/main.tf @@ -1,12 +1,13 @@ resource "aws_instance" "my_first_linux" { - instance_type = "t2.micro" - ami = "ami-06971c49acd687c30" + instance_type = "t2.micro" + ami = "ami-06971c49acd687c30" security_groups = ["ssh-access-witch"] + iam_instance_profile = aws_iam_instance_profile.daphodell_profile.name - tags = { - Name = "labs" - } + tags = { + Name = "labs" + } } resource "aws_s3_bucket" "resume-bucket" { @@ -61,6 +62,11 @@ resource "aws_iam_role" "daphodell_role" { } } +resource "aws_iam_instance_profile" "daphodell_profile" { + name = "daphodell_profile" + role = aws_iam_role.daphodell_role.name +} + ## Policies ## Allow user CLI -> S3 read/write resource "aws_iam_policy" "assume_role_s3_policy" { diff --git a/lab-3/terraform/providers.tf b/terraform/providers.tf similarity index 100% rename from lab-3/terraform/providers.tf rename to terraform/providers.tf