terraform

How to add Virtual Machine User Login roles to a list of users by Terraform?

99封情书 提交于 2020-03-25 16:11:05
问题 a@cc.com & b@cc.com are E-mail addresses of our organization. These emails are also used as the Azure login accounts. I've set up a Terraform code to use the AzureAD to access to the VM in Azrue. My question is How Can I grand those accounts the role of Virtual Machine User Login ? resource "azurerm_role_assignment" "test" { scope = "${data.azurerm_management_group.primary.id}" role_definition_id = "Virtual Machine User Login" principal_id = "a@cc.com, b@cc.com" } The official documents says

Make a resource schema dependant on another variable

孤街醉人 提交于 2020-03-24 03:06:50
问题 I'm creating a plugin in Terraform and I want to add a field to the schema which can be called only when another field has been provided. "host_name": &schema.Schema{ Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("host_name", nil), Description: "Should give name in FQDN if being used for DNS puposes .", }, "enableDns": &schema.Schema{ Type: schema.TypeString, Required: true, DefaultFunc: schema.EnvDefaultFunc("host_name", nil), Description: "Should give name in

Weird behavior of Terraform's random_shuffle provider

耗尽温柔 提交于 2020-03-23 23:57:10
问题 I have the following configuration: variable "private_subnets" { default = ["subnet-A", "subnet-B"] } resource "random_shuffle" "az" { input = ["${var.private_subnets}"] result_count = 1 } module "server" { source = "./modules/aws-ec2" instance_count = 3 name = "${var.env}-server" stack = "server" role = "server" ami = "${lookup(var.aws_amis, var.aws_region, "")}" instance_type = "t2.micro" subnet_id = "${random_shuffle.az.result[0]}" vpc_security_group_ids = ["${var.security_groups}"] } I

Fix “Interpolation-only expressions are deprecated” warning in Terraform

孤街浪徒 提交于 2020-03-18 12:02:37
问题 I upgraded to Terraform v0.12.16 and now I am getting a lot of messages that look like this: Warning: Interpolation-only expressions are deprecated on ../modules/test-notifier/test_notifier.tf line 27, in resource "aws_sns_topic_policy" "default": 27: arn = "${aws_sns_topic.default.arn}" Terraform 0.11 and earlier required all non-constant expressions to be provided via interpolation syntax, but this pattern is now deprecated. To silence this warning, remove the "${ sequence from the start

Define node names from node groups

人走茶凉 提交于 2020-03-05 02:42:48
问题 I'm using nodegroups into my terraform script and I was wondering how can I set the name of instances from nodegroups: resource "aws_eks_node_group" "node_group" { count = length(var.public_subnet_ids) cluster_name = aws_eks_cluster.cluster.name node_group_name = "node-group-${count.index}" node_role_arn = aws_iam_role.nodes.arn subnet_ids = [var.public_subnet_ids[count.index]] instance_types = [var.node-instance-type] ... } Without nodegroups I was doing: resource "aws_launch_configuration"

How to specify dead letter dependency using modules?

随声附和 提交于 2020-03-04 05:40:18
问题 I have the following core module based off this official module: module "sqs" { source = "github.com/terraform-aws-modules/terraform-aws-sqs?ref=0d48cbdb6bf924a278d3f7fa326a2a1c864447e2" name = "${var.site_env}-sqs-${var.service_name}" } I'd like to create two queues: xyz and xyz_dead. xyz sends its dead letter messages to xyz_dead. module "xyz_queue" { source = "../helpers/sqs" service_name = "xyz" redrive_policy = <<POLICY { "deadLetterTargetArn" : "${data.TODO.TODO.arn}", "maxReceiveCount"

Cannot access Azure Devops Git repo from release pipeline using Service Principal

笑着哭i 提交于 2020-03-03 12:06:28
问题 We're creating Terraform modules for Azure resources; we've given each it's own repo within a project, but when trying to call the module in the release pipeline, we get a time out, or an error 128. This works outside the pipeline as a user with rights to deploy, however we're using a service principal to deploy within the release pipeline, which also has the correct rights; It looks like the issue is that Service Principals have no rights in Azure DevOps. We've tried initially on a hosted

Cannot access Azure Devops Git repo from release pipeline using Service Principal

纵饮孤独 提交于 2020-03-03 12:04:25
问题 We're creating Terraform modules for Azure resources; we've given each it's own repo within a project, but when trying to call the module in the release pipeline, we get a time out, or an error 128. This works outside the pipeline as a user with rights to deploy, however we're using a service principal to deploy within the release pipeline, which also has the correct rights; It looks like the issue is that Service Principals have no rights in Azure DevOps. We've tried initially on a hosted

pass output from terraform to Azure Devops Pipeline with state file in azure backend store

天大地大妈咪最大 提交于 2020-03-03 09:01:11
问题 I cannot seem to retrieve the public ip address output of Terraform for next step in build pipeline in AzureDevops. Terraform state pull works and outputs to json file, cannot grep on output. Terraform state show [options] ADDRESS does not support azure backend so cannot use or grep or filter the output also tried to store as file and read in the value. resource "local_file" "foo" { content = "foo!" filename = "${path.module}/foo.bar" } data "azurerm_public_ip" "buildserver-pip" { name = "$

How to get the most recent shared AWS RDS snapshot by id?

不打扰是莪最后的温柔 提交于 2020-03-02 09:47:01
问题 I have 2 databases on AWS RDS, one for stage and one for production across 2 accounts. I am trying to copy the data in production to stage every x days. My plan was to make a copy of the most recent automatic backup snapshot in production and share it to the stage account before creating the database in stage using the shared snapshot from production . Everything was going right until I ran into what I believe is a bug but it could easily be that I made a mistake. When I tried to get the most