terraform

Terraform Resource: Connection Error while executing apply?

痞子三分冷 提交于 2021-02-10 12:49:44
问题 I am trying to login to ec2 instance that terraform will create with the following code: resource "aws_instance" "sess1" { ami = "ami-c58c1dd3" instance_type = "t2.micro" key_name = "logon" connection { host= self.public_ip user = "ec2-user" private_key = file("/logon.pem") } provisioner "remote-exec" { inline = [ "sudo yum install nginx -y", "sudo service nginx start" ] } } But this gives me an error: PS C:\Users\Amritvir Singh\Documents\GitHub\AWS-Scribble\Terraform> terraform apply

Terraform Resource: Connection Error while executing apply?

可紊 提交于 2021-02-10 12:48:31
问题 I am trying to login to ec2 instance that terraform will create with the following code: resource "aws_instance" "sess1" { ami = "ami-c58c1dd3" instance_type = "t2.micro" key_name = "logon" connection { host= self.public_ip user = "ec2-user" private_key = file("/logon.pem") } provisioner "remote-exec" { inline = [ "sudo yum install nginx -y", "sudo service nginx start" ] } } But this gives me an error: PS C:\Users\Amritvir Singh\Documents\GitHub\AWS-Scribble\Terraform> terraform apply

Error creating IAM Role. MalformedPolicyDocument: Has prohibited field Resource. Terraform

南笙酒味 提交于 2021-02-10 06:28:06
问题 I have seen several links, but I have to see an example. I have: resource "aws_iam_role" "role" { name = "role" assume_role_policy = <<-EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1590217939125", "Action": "s3:*", "Effect": "Allow", "Resource": "arn:aws:s3:::wwe" }, { "Sid": "Stmt1590217939125", "Action": "s3:*", "Effect": "Allow", "Resource": "arn:aws:s3:::wwe/*" }, { "Sid": "Stmt1577967806846", "Action": [ "secretsmanager:DescribeSecret", "secretsmanager:GetRandomPassword",

Terraform using IAM role assume

大城市里の小女人 提交于 2021-02-10 05:07:59
问题 I have been using access/secret keys with terraform to create/manage our infrastructure in AWS. However, I am trying to switch to using IAM role instead. I should be able to use a role in my account and assume the role in another account and should be able to run plan, apply etc to build infra in the other account. Any ideas, please suggest. So far, I am testing with https://www.terraform.io/docs/providers/aws/, but for some reason, it is not working for me or the instructions are not clear

Terraform: Issue with assume_role

本秂侑毒 提交于 2021-02-09 11:17:04
问题 I'm trying to solve this mystery for few days now, but no joy. Basically, Terraform cannot assume role and failing with: Initializing the backend... 2019/10/28 09:13:09 [DEBUG] New state was assigned lineage "136dca1a-b46b-1e64-0ef2-efd6799b4ebc" 2019/10/28 09:13:09 [INFO] Setting AWS metadata API timeout to 100ms 2019/10/28 09:13:09 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id 2019/10/28 09:13:09 [INFO] AWS Auth provider used:

Terraform: Issue with assume_role

安稳与你 提交于 2021-02-09 11:13:03
问题 I'm trying to solve this mystery for few days now, but no joy. Basically, Terraform cannot assume role and failing with: Initializing the backend... 2019/10/28 09:13:09 [DEBUG] New state was assigned lineage "136dca1a-b46b-1e64-0ef2-efd6799b4ebc" 2019/10/28 09:13:09 [INFO] Setting AWS metadata API timeout to 100ms 2019/10/28 09:13:09 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id 2019/10/28 09:13:09 [INFO] AWS Auth provider used:

Terraform: Issue with assume_role

夙愿已清 提交于 2021-02-09 11:12:39
问题 I'm trying to solve this mystery for few days now, but no joy. Basically, Terraform cannot assume role and failing with: Initializing the backend... 2019/10/28 09:13:09 [DEBUG] New state was assigned lineage "136dca1a-b46b-1e64-0ef2-efd6799b4ebc" 2019/10/28 09:13:09 [INFO] Setting AWS metadata API timeout to 100ms 2019/10/28 09:13:09 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id 2019/10/28 09:13:09 [INFO] AWS Auth provider used:

Is there a way to define multiple source_file for Terraform archive provider?

我们两清 提交于 2021-02-09 09:54:56
问题 I am using the Terraform archive_file provider to package multiple files into a zip file. It works fine when I define the archive like this: data "archive_file" "archive" { type = "zip" output_path = "./${var.name}.zip" source_dir = "${var.source_dir}" } However I don't want the archive to contain all of the files in var.source_dir , I only want a subset of them. I notice the archive_file provider has a source_file attribute so I was hoping I could supply a list of those files and package

How can I get active address space of tagged Azure VNets inside Terraform?

三世轮回 提交于 2021-02-08 11:15:27
问题 I would like to get with Terraform the active address space of VNets for Azure in Terraform that have a certain tag. For this I thought I could use Resource data source for virtual networks: data "azurerm_resources" "vnets"{ type = "Microsoft.Network/virtualNetworks" required_tags = { tag_name = "tag" } } Then I realized that required attribute "address_space" belongs actually to the Virtual Networks Data Source (https://www.terraform.io/docs/providers/azurerm/r/virtual_network.html). Still I

Terraform: CloudWatch Event that notifies SNS

别等时光非礼了梦想. 提交于 2021-02-08 07:21:59
问题 I'm learning TF and trying to apply an infrastructure that creates: a simple lambda function an SNS topic get that lambda to subscribe the SNS topic a Cloud Watch Event that publishes a message to the topic at some interval a Cloud Watch Log Group to check if the lambda gets notified by the SNS The lambda permission to allow calls from SNS I'm able to apply that successfully. The infrastructure seems perfectly fine (it has the same aspect when I create that myself through the visual aws