This repository contains Terraform code for creating AWS resources using modules and resources.
To import an existing resource, use the following command:
terraform import resource-type.resource-name attribute_or_id
Make sure to replace resource-type.resource-name
and attribute_or_id
with the specific resource and its attribute or ID.
To retrieve modules, run the following command:
terraform get
The IAM User module is used to create an IAM user in AWS.
module "iam_iam-user" {
source = "terraform-aws-modules/iam/aws//modules/iam-user"
version = "3.4.0"
name = "max"
create_iam_access_key = false
create_iam_user_login_profile = false
}
The following AWS resources are defined in the Terraform code:
resource "aws_iam_user" "cloud" {
name = split(":", var.cloud_users)[count.index]
count = length(split(":", var.cloud_users))
}
resource "aws_s3_bucket" "sonic_media" {
bucket = var.bucket
}
resource "aws_s3_object" "upload_sonic_media" {
bucket = aws_s3_bucket.sonic_media.id
key = substr(each.value, 7, 20)
source = each.value
for_each = var.media
}
resource "aws_instance" "mario_servers" {
ami = var.ami
tags = {
name = var.name
}
instance_type = var.name == "tiny" ? var.small : var.large
}