Flashcards
7 Terraform AWS
Cards in this deck (15)
- 1Create user Lucy with Terrform with admin-user right and tag Description leaderFilq main.tf
resource "aws_iam_user" "admin-user" {
name = "lucy"
tags = {
Decription = "leader"
}
} - 2What will happen if we execute terraform plan after previous flash?2 errors will arise - we need enter region
and
we will need to provide credential to connect to aws - 3How can we fix error happened in previous flash card?Add following to main.tf
provider "aws" {
region = "some region"
access_key = "key to aws"
secret_key = "secret key to aws"
} - 4What is better way of providing cedentials?using aws cli
- 5How provide credentials using environment variables?export AWS_ACCESS_KEY_ID = ""
export AWS_SECRET_ACCESS_KEY_ID = " " - 6Add IAM policyresource "aws_iam_policy" "adminUser" {
name = "AdminUsers"
policy = < - 7Write JSON file indicated in previous answer{
"Version": "2012-10-17"
"Statement": [
{
"Effect" : "Allow",
"Action": "*",
"Resource" : "*"
}
]
} - 8Attach IAM policy to IAM userresource "aws_iam_user_policy_attachment" "lucy-admin-access" {
user = aws_iam_user.admin-user.name
policy_arn = aws_iam_policy.adminUser.arn
} - 9Add JSON file to resource block using file function.First create somefile.json in the same directory and add json config to this file
Then modify resource block like this
resource "aws_iam_policy" "adminUser" {
name = "AdminUsers"
policy = file("somefile.json"
} - 10Create AWS S3 bucket named finance with attribute bucket (finance - 1111) and tags (Description - finance)resource "aws_s3_bucket " "finance" {
bucket ="finance -1111"
tags ={
Description ="Finance"
}
} - 11Add /root/finance/finance-2020.doc to bucket finance created earlierresource "aws_s3_bucket_object " "finance-2020" {
content = "/root/finance/finance-2020.doc"
key = "finance-2020.doc"
bucket = aws_s3_bucket.finance.id
} - 12Add info to main.tf file about finance-analysts group which was not created by terraform and call it finance-datadata "aws_iam_group" "finance-data" {
group_name = "finance-analysts"
} - 13Create bucket policyresource "aws_s3_bucket_policy" "finance-policy" {
bucket = aws_s3_bucket.finance.id
policy = < - 14Add JSON policy to previous flashcard{
"Version": "2012-10-17"
"Statement": [
{
"Effect" : "Allow",
"Action": "*",
"Resource" : "arn:aws:s3:::$(aws_s3_bucket.finance.id)/*",
"Principal": {
"AWS" : [
"${data.aws_iam_group.finance-data.arn}"
]
}
}
]
} - 15I will add Dynamo DB later to this section
Information
- Description
- Easy Kodekloud Terraform basics Flashcards on 7 Terraform AWS, created by Archimed Nemes on 18/12/2022.
- Created by
- Archimed Nemes
- Views
- 0
- Rating