First create an IAM access in an AWS account, so that we will connect Terraform with AWS, and execute our Iaac.
create a user account and give permissions.
Normally we should write our policy of access, but for a demo purpose I only give them a full permission.
I have added two permission for my demo purpose.
Use access key to login into AWS , through the local host and execute the terraform commands.
Generate Access-Key.
Region where we want to connect. use the site link to pick the terraform code.
https://registry.terraform.io/providers/hashicorp/aws/latest/docs
Use the code to create the S3 Bucket.
resource "aws_s3_bucket" "example" {
bucket = "my-tf-test-bucket"
tags = {
Name = "My bucket"
Environment = "Dev"
}
}
Follow the process to execute the terraform commands.
terraform init
terraform plan
terraform apply
Result 1:
Demo Code:
resource "aws_instance" "EC2-1" {
ami = "ami-03f65b8614a860c29
instance_type = "t2.micro"
tags = {
Name = "EC2-1"
}
}
Result:
Destroy created Resources in AWS Cloud.
—
END OF NOTES
No comments:
Post a Comment