question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I am wondering how can we stop and restart the AWS ec2 instance created using terraform. is there any way to do that?
As you asked, for example, there is a limit on the comment, so posting as the answer using local-exec. I assume that you already configure aws configure | aws configure --profile test using aws-cli. Here is the complete example to reboot an instance, change VPC SG ID, subnet and key name etc provider "aws" { region ...
Terraform
57,158,310
12
Does anyone know if it's possible with possibly code snipits representing whether I can create a map variable within a map variable in terraform variables? variable "var" { type = map default = { firstchoice = { firstAChoice ="foo" firstBChoice = "bar" } secondchoice = { secondAChoice ...
Yes, it's possible to have map variable as value of map variable key. Your variable just needed right indentation. Also I am putting ways to access that variable. variable "var" { default = { firstchoice = { firstAChoice = "foo" firstBChoice = "bar" } secondchoice = { secondAChoice = "f...
Terraform
56,776,130
12
I'm trying to build an ElasticSearch cluster using Terraform but i'm not able to assign more that 1 subnet! That's really weird cause in the documentation there is this : https://www.terraform.io/docs/providers/aws/r/elasticsearch_domain.html#subnet_ids subnet_ids - (Required) List of VPC Subnet IDs for the Elasticse...
You're missing zone_awareness_enabled parameter in the cluster_config which is required when using multi AZ Elasticsearch clusters.
Terraform
56,594,965
12
I'd like to use Terraform to create AWS Cognito User Pool with one test user. Creating a user pool is quite straightforward: resource "aws_cognito_user_pool" "users" { name = "${var.cognito_user_pool_name}" admin_create_user_config { allow_admin_create_user_only = true unused_account_validity_days = 7 } }...
In order to automate things, it can be done in terraform using a null_resource and local_exec provisioner to execute your aws cli command e.g. resource "aws_cognito_user_pool" "pool" { name = "mypool" } resource "null_resource" "cognito_user" { triggers = { user_pool_id = aws_cognito_user_pool.pool.id } ...
Terraform
55,087,715
12
I have set-up a terraform project with a remote back-end on GCP. Now when I want to deploy the infrastructure, I run into issues with credentials. I have a credentials file in \home\mike\.config\gcloud\credentials.json In my terraform project I have the following data referring to the remote state: data "terraform_re...
I was facing the same error when trying to run terraform (version 1.1.5) commands in spite of having successfully authenticated via gcloud auth login. Error message in my case: Error: storage.NewClient() failed: dialing: google: could not find default credentials. See https://developers.google.com/accounts/docs/applic...
Terraform
55,068,363
12
I can't seem to get an SSL certificate from ACM working on API-Gateway, Route53, using terraform. There seems to be an interdependency problem. data "aws_route53_zone" "root_domain" { name = "${var.route53_root_domain_name}" private_zone = false } # The domain name to use with api-gateway resource "aws_api...
I seem to have fixed the problem by adding the certificate validation records to the root domain instead of the sub domain. Therefore breaking the cyclic dependency. The problem appears to be that the sub domain can't be created without the certificate and the certificate can't be validated without the sub domain. So t...
Terraform
55,031,167
12
I am testing out some Terraform code to create a Kubernetes cluster so I chose the smallest/cheapest VM resource "azurerm_kubernetes_cluster" "k8s" { name = "${var.cluster_name}" location = "${azurerm_resource_group.resource_group.location}" resource_group_name = "${azurerm_resourc...
You need to select an instance with at least 3.5 GB of memory. Read A note on node size from this blog. You can list the VM size and price on the Azure sales site. Currently, the cheapest is Standard_B2s with 4 GB RAM. You can also sort it directly in the Azure portal.
Terraform
54,876,474
12
So, i've got Aurora MySql cluster with one RDS MySql instance provisioned. The obstacle occurs with the AWS underlying API allowing only for 1 logical DB to be created. Thus, I was wondering if any of you already had experience with such deployment coz I am running away from having to use Mysql client CLI for this step...
Terraform has a Mysql provider https://www.terraform.io/docs/providers/mysql/index.html: # Configure the MySQL provider provider "mysql" { endpoint = "my-database.example.com:3306" username = "app-user" password = "app-password" } # Create a Database resource "mysql_database" "app" { name = "my_awesome_app" } ...
Terraform
52,542,244
12
I've got a very simple piece of Terraform code: provider "aws" { region = "eu-west-1" } module ec2 { source = "./ec2_instance" name = "EC2 Instance 1" } where the module is: variable "name" { default = "Default Name from ec2_instance.tf" } resource "aws_instance" "example" { ami = "ami-e5083683" insta...
You are incorrectly assigning a vpc_security_group_id into security_groups, instead of into vpc_security_group_ids. Change security_groups = [ "sg-7310e10b" ] to vpc_security_group_ids = [ "sg-7310e10b" ] and everything will be ok.
Terraform
51,496,944
12
AWS ALB supports rules based on matching both host and path conditions in the same rule. You can also create rules that combine host-based routing and path-based routing. I've checked the console and the UI does indeed allow for selecting host and path conditions in the same rule. Terraform aws_alb_listener_rule seem...
You can specify two conditions, which results in an AND of the two conditions: resource "aws_alb_listener_rule" "host_header_rule" { condition { field = "host-header" values = ["some.host.name"] } condition { field = "path-pattern" values = ["/some-path/*"] } # etc. }
Terraform
46,304,015
12
I am trying to provision some AWS resources, specifically an API Gateway which is connected to a Lambda. I am using Terraform v0.8.8. I have a module which provisions the Lambda and returns the lambda function ARN as an output, which I then provide as a parameter to the following API Gateway provisioning code (which is...
You are right about the explicit dependency declaration. Normally Terraform would be able to figure out the relationships and schedule create/update/delete operations accordingly to that - this is mostly possible because of the interpolation mechanisms under the hood (${resource_type.ref_name.attribute}). You can displ...
Terraform
42,760,387
12
Let's say that I have a public hosted zone names example.com.. I use the following piece of Terraform code to dynamically fetch the hosted zone id based on the name as per the docs. data "aws_route53_zone" "main" { name = "example.com." # Notice the dot!!! private_zone = false } During terraform plan it comes up w...
The aws_route53_zone data source will list all the hosted zones in the account that Terraform has permissions to view. If you are trying to reference a zone in another account then you can do this by creating a role/user in the account with the zone that has permissions to list all the zones (route53:ListHostedZones*,r...
Terraform
41,631,966
12
I'm facing a choice terraform of gcloud deployment manager. Both tools provide similar functionality and unfortunately lacks all resources. For example: gcloud can create service account (terraform cannot) terraform can manage DNS record set (gcloud cannot) and many others ... Questions: Can you recommend one tool o...
Someone may say this is not a question you should ask on stackoverflow, but I will answer anyway. It is possible to combine multiple tools. The primary tool you should run is Terraform. Use Terraform to manage all resources it supports natively, and use external provider to invoke gcloud (or anything else). While it wi...
Terraform
41,040,306
12
My question is similar to this git hub post, but unfortunately it is unsolved: https://github.com/hashicorp/terraform/issues/550 I want a simple way to give sudo privileges to the commands run in the provisioner "remote-exec" { } block of my terraform scripts. I am coming from an ansible background that has the sudo: y...
The answer was to use the following syntax in my first sudo command: "echo yourPW | sudo -S someCommand" This bypasses the sudo password prompt and enters the password directly into the command. I already had my sudo password as a variable "${var.pw}" so running my sudo commands was the simple matter of changing my ...
Terraform
37,847,273
12
I'm trying to create an S3 bucket using Terraform, but keep getting Access Denied errors. I have the following Terraform code: resource "aws_s3_bucket" "prod_media" { bucket = var.prod_media_bucket acl = "public-read" } resource "aws_s3_bucket_cors_configuration" "prod_media" { bucket = aws_s3_bucket.prod_media....
There are few issues in your code: acl attribute of aws_s3_bucket is deprecated and shouldn't be used. You don't have aws_s3_bucket_ownership_controls You don't have aws_s3_bucket_public_access_block You are missing relevant depends_on aws_iam_user_policy can't use aws_s3_bucket_policy.prod_media_bucket.id (its not ev...
Terraform
76,419,099
11
We have a few terraform configurations for which we use s3 as the backend. We have multiple AWS accounts, one for each of our environments. In all the environments and across multiple region, we have different s3 bucket & dynamodb_table names used which as of now do not follow a valid convention and make it difficult t...
Did you try to copy the StateFile From old bucket to new bucket and then change the S3 bucket in terraform backend configuration
Terraform
69,735,414
11
I have a single main.tf at the root and different modules under it for different parts of my Azure cloud e.g. main.tf - apim - firewall - ftp - function The main.tf passes variable down to the various modules e.g. resource group name or a map of tags. During development I have been investigating certain functi...
You can target only the module by specifying the module namespace as the target argument in your plan and apply commands: terraform plan -target=module.<declared module name> For example, if your module declaration was: module "the_firewall" { source = "${path.root}/firewall" } then the command would be: terraform ...
Terraform
68,408,060
11
I have a dynamic block like so: dynamic "origin" { for_each = var.ordered_cache_behaviors content { domain_name = "${origin.value.s3_target}.s3.amazonaws.com" origin_id = "S3-${origin.value.s3_target}" } } My list is defined like so: "ordered_cache_behavior...
The dynamic block for_each argument expects to receive a collection that has one element for each block you want to generate, so the best way to think about your problem is to think about producing a filtered version of var.ordered_cached_behaviors that only contains the elements you want to use to create blocks. The u...
Terraform
67,644,692
11
I am trying to increase size of my root volume for my ami ami-0d013c5896434b38a - I am using Terraform to provision this. Just to clarify - I have only one instance. And I want to make sure that if I need to increase the disk space, I don't have to destroy the machine first. Elasticity (EC2) is my reason to believe th...
I'm running Terraform 1.0.1 and would like to change my volume_size from 20gb to 30gb. After run terraform apply [...] # aws_instance.typo3_staging_1 will be updated in-place ~ resource "aws_instance" "staging_1" { id = "i-0eb2f8af6c8ac4125" tags = { "Name" = ...
Terraform
67,210,801
11
I'm trying to call multiple modules from terragrunt. I understand that currently, terragrunt doesn't support multiple sources and we can only call one module at a time. So, I created a main.tf file to frontend multiple modules. # main.tf module "foo" { source = "../modules/vpc" } module "bar" { source = "../m...
In short, yes, the two files snippets you've posted would work. terragrunt doesn't support multiple sources and we can only call one module at a time. Longer answer: It's useful to think of the terraform { ... } block in your terragrunt.hcl as a pointer to a "root terraform module". This root module is just any other...
Terraform
66,362,864
11
I'm trying to upgrade from terraform 0.12 to 0.13. it seems to have no specific problem of syntax when I run terraform 0.13upgrade nothing is changed. only a file version.tf is added +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + } + } + required_version = ">= 0.13" +} and whe...
I followed the steps here terraform state replace-provider registry.terraform.io/-/template registry.terraform.io/hashicorp/template terraform state replace-provider registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws and it fixed my problem.
Terraform
65,583,605
11
Problem: I want to be able to granularly create/modify a PostgreSQL CloudSQL instance in Google Cloud Platform with Terraform. Currently there is a setting tier = "<instance_type>" Example: Taken from Terraform documentation name = "master-instance" database_version = "POSTGRES_11" region = ...
The instance tier is the machine type and and for custom machine types you can set the values in that variable like this: db-custom-<CPUs>-<Memory_in_MB> so for example in your case would be: name = "master-instance" database_version = "POSTGRES_11" region = "us-central1" settings { #...
Terraform
64,682,873
11
I have a sample map like below and am trying to remove any accounts that have a key2 value matching 'bong'. So the starting map would look like this: sample_map={ account1 = { key1 ="foo" key2 ="bar" } account2 = { key1 ="bing" key2 ="bong" } } And the end result...
You were almost there, if I understand correctly. It should be: contains(values(v), var.exclude) The working example is below: variable "sample_map" { default ={ account1 = { key1 ="foo" key2 ="bar" } account2 = { key1 ="bing" key2 ="bong" } ...
Terraform
63,463,671
11
I am using Terraform for most of my infrastructure, but at the same time I'm using the serverless framework to define some Lambda functions. Serverless uses CloudFormation under the hood where I need access to some ARNs for resources created by Terraform. My idea was to create a CloudFormation stack in Terraform and ex...
You can use AWS::CloudFormation::WaitConditionHandle for this. Example: Resources: NullResource: Type: AWS::CloudFormation::WaitConditionHandle
Terraform
62,990,653
11
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...
One issue is that you have two statements with the same Sid: Stmt1590217939125. Sids must be unique. From the docs: In IAM, the Sid value must be unique within a JSON policy. The second issue is that assume_role_policy is for a trust policy. Trust policies do not have Resource. They have different form. For instance:...
Terraform
61,971,160
11
I'm trying to import an existing resources into the terraform state. I used the following: terraform import azurerm_resource_group.main_rg /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-cm-main The resource group exist in the subscription with the name and ID. but when I run the command, I get ...
I've seen the problem as well. For me it worked to set the correct subscription in my az cli tool. For some reason it was trying to find the resource via az cli in the wrong subscription. az account list -o table az account set -s
Terraform
60,723,765
11
I want to deploy my terraform infrastructure with an Azure DevOps pipeline, but I'm running into a problem with the storage account firewall. Here an example for a storage account: resource "azurerm_storage_account" "storage_account" { name = "mystorageaccount" resource_group_name ...
For Terraform I would suggest running own agent pools. The agent pools for production environments should be separate from non production and should be located in separate vNets. Then add a network rule to your Storage Account to allow access from the agent pool subnet. The same will happen to most of the services when...
Terraform
60,486,835
11
I looked at the documentation of both azurerm_app_service and azurerm_application_insights and I just do not see a way to tie them. Yet on the App Service page in the portal there is a link to Application Insights, currently grayed out: So, how do I enable it with terraform?
You need numerous app settings to get this to work properly as intended. The ones I had to add to get it all working were: "APPINSIGHTS_INSTRUMENTATIONKEY" "APPINSIGHTS_PROFILERFEATURE_VERSION" "APPINSIGHTS_SNAPSHOTFEATURE_VERSION" "APPLICATIONINSIGHTS_CONNECTION_STRING" "ApplicationInsightsAgent_EXTENSION_VERSION" "...
Terraform
60,175,600
11
I am trying to serve a static content using AWS API Gateway. When I attempt to invoke the URL, both from the test page and from curl, I get the error: "Execution failed due to configuration error: statusCode should be an integer which defined in request template". This is my configuration on Terraform: resource "aw...
Just to repost the excellent answer of TheClassic here, the format seems to be: request_templates = { "application/json" = jsonencode( { statusCode = 200 } ) } I also had this same problem, but looks like this works.
Terraform
59,911,777
11
I'm using Terraform to launch my cloud environments. It seems that even minor configuration change affects many of the resources behind the scenes. For example, In cases where I create AWS instances - a small change will lead to auto-generation of all the instances: -/+ aws_instance.DC (new resource required) i...
Terraform resources only force a new resource if there's no clear upgrade path when modifying a resource to match the new configuration. This is done at the provider level by setting the ForceNew: true flag on the parameter. An example is shown with the ami parameter on the aws_instance resource: Schema: map[st...
Terraform
59,309,243
11
I have terraform directory structure as below: terraform/ main.tf modules outputs.tf provider.tf variables.tf ./modules: compute network resourcegroup ./modules/compute: main.tf outputs.tf variables.tf ./modules/network: main.tf outputs.tf variables.tf ./modules/resourcegroup: main.tf outputs.tf variabl...
Go through the repo you are working on (https://github.com/ameyaagashe/help_me_cross/tree/d7485d2a3db339723e9c791e592b2f1dbc1f0788) . It makes sense for me now. The problem is, you mix the idea on how to use public modules with your own created modules. In fact, you needn't set any modules to reference other public t...
Terraform
59,081,428
11
If I create a varaible definition like this: variable "aws_ecs_config" { type = object({ cpu = number memory = number ecs_image_address = string }) logs = { type = object({ group = string region = string stream_prefix = string }) } } ...
It is not possible to re-use variable declarations in Terraform. If variables in different modules will have the same type, that type must be repeated in each module. Terraform has a structural type system rather than a nominal type system, so types themselves are not named and instead are matched/constrained by their ...
Terraform
58,772,935
11
In my current terraform configuration I am using a static JSON file and importing into terraform using the file function to create an AWS IAM policy. Terraform code: resource "aws_iam_policy" "example" { policy = "${file("policy.json")}" } AWS IAM Policy definition in JSON file (policy.json): { "Version": "2012-...
The aws_iam_policy_document data source from aws gives you a way to create json policies all in terraform, without needing to import raw json from a file or from a multiline string. Because you define your policy statements all in terraform, it has the benefit of letting you use looping/filtering on your principals arr...
Terraform
57,824,936
11
I am new to templates, I am trying to change terraform modules to flex as many “nameservers” as needed. How can iterate through the values of variable? Right now I am doing: template.tf variable "nameserver" { type = list(string) } nameservers = [ "174.15.22.20", "174.15.12.21" ] nameserver_1 = element(var.name...
From what you've shown of template.tf I'm guessing that vars = { ... } declaration is inside a data "template_file" block. The template_file data source is primarily there for Terraform 0.11 compatibility and it only supports string values for the template variables, but since you are using Terraform 0.12 you can use t...
Terraform
57,561,084
11
CloudFormation provides AllowedValues for Parameters which tells that the possible value of the parameter can be from this list. How can I achieve this with Terraform variables? The variable type of list does not provide this functionality. So, in case I want my variable to have value out of only two possible values, h...
I don't know of an official way, but there's an interesting technique described in a Terraform issue: variable "values_list" { description = "acceptable values" type = "list" default = ["true", "false"] } variable "somevar" { description = "must be true or false" } resource "null_resource" "is_variable_value_va...
Terraform
54,254,524
11
I'm trying to create a CodeBuild project using Terraform, but when I build I'm getting the following error on the DOWNLOAD_SOURCE step: CLIENT_ERROR: repository not found for primary source and source version This project uses a CodeCommit repository as the source. It's odd because all of the links to the repository f...
Your problem is the specification of the source: source { type = "CODECOMMIT" location = "mycompany-devops-us-east-1" Here's the Amazon documentation for the source, what's relevant with some emphasis: For source code in an AWS CodeCommit repository, the HTTPS clone URL to the repository that contains the so...
Terraform
53,785,769
11
I am facing an issue in terraform where I want to read details of some existing resource (r1) created via AWS web console. I am using those details in creation on new resource (r2) via terraform. Problem is that it is trying to destroy and recreate that resource which is not desired as it will be failed. How can I mana...
The import statement is meant for taking control over existing resources in your Terraform setup. If your only intention is to derive information on existing resources (outside of your Terraform control), data sources are designed specifically for this need: data "aws_lb" "r1" { name = "lb_foo" arn = "some_spe...
Terraform
53,514,465
11
I would like to replace the 3 indepedent variables (dev_id, prod_id, stage_id), for a single list containing all the three variables, and iterate over them, applying them to the policy. Is this something terraform can do? data "aws_iam_policy_document" "iam_policy_document_dynamodb" { statement { effect = ...
Given you have the list of account ids, have you tried this? var "accounts" { default = ["123", "456", "789"] type = "list" } locals { accounts_arn = "${formatlist("arn:aws:iam::%s", var.accounts)}" } Then in your policy document: principals { type = "AWS" identifiers = ["${local.accounts_arn}"] } I haven'...
Terraform
52,837,358
11
I have defined the following Terraform module: module "lambda" { source = "../lambda" region = "us-west-1" account = "${var.account}" } How can I take advantage from the module name to set the source parameter with an interpolation? I wish something like: module "lamb...
locals { module = basename(abspath(path.module)) } { ... some-id = local.module ... }
Terraform
52,603,758
11
I have been trying to use the same terraform stack to deploy resources in multiple azure subscriptions. Also need to pass parameters between these resources in different subscriptions. I had tried to use multiple Providers, but that is not supported. Error: provider.azurerm: multiple configurations present; only on...
You can use multiple providers by using alias (doku). # The default provider configuration provider "azurerm" { subscription_id = "xxxxxxxxxx" } # Additional provider configuration for west coast region provider "azurerm" { alias = "y" subscription_id = "yyyyyyyyyyy" } And then specify whenever you want to use...
Terraform
51,714,639
11
I'm creating a bucket using a module, how can I find the ARN for that bucket? create the module module "testbucket" { source = "github.com/tomfa/terraform-sandbox/s3-webfiles-bucket" aws_region = "${var.aws_region}" aws_access_key = "${var.aws_access_key}" aws_secret_key = "${var.aws_secret_key}" bucke...
Your module will need to have an outputs.tf file, looking like this: output "bucket_arn" { value = "${aws_s3_bucket.RESOURCE_NAME.arn}" } Please note that you will have to replace RESOURCE_NAME with the name of the terraform S3 bucket resource. For example, if your resource looks like this: resource "aws_s3_bucket" ...
Terraform
51,278,407
11
I have created an EC2 instance on AWS using terraform; What I want is to add a user in the OS level and provide a particular key to be added in its ~/.ssh/authorized_keys file. The aws_instance documentation does not seem to list this functionality. Is there a way to go about this? edit: I think a way to do this is via...
Following up on comments and edits, what you are looking for might look like this: resource "aws_instance" "default" { ... provisioner "remote-exec" { inline = [ "sudo useradd someuser" ] connection { type = "ssh" user = "ubuntu" private_key = "${file("yourkey.pem"...
Terraform
50,947,490
11
Right now I have the following in my main.tf: resource "aws_lambda_function" "terraform_lambda" { filename = "tf_lambda.zip" function_name = "tf_lambda" role = "lambda_basic_execution" handler = "tf_lambda.lambda_handler" source_code_hash = "${base64sha256(file("tf_lambda.zip"))}" runtime = "python3.6" } M...
You may also try this using archive_file, https://www.terraform.io/docs/providers/archive/d/archive_file.html So that when you run "terraform apply" the file will be re-zipped and uploaded. data "archive_file" "zipit" { type = "zip" source_file = "tf_lambda/tf_lambda.py" output_path = "tf_lambda.zip" } r...
Terraform
50,357,651
11
Does it make sense to understand that it runs in the order defined in main.tf of terraform? I understand that it is necessary to describe the trigger option in order to define the order on terraform. but if it could not be used trigger option like this data "external" , How can I define the execution order? For examp...
I can only provide feedback on the code you provided but one way to ensure the test_status command is run once the DB is ready is to use a depends_on within a null_resource resource "null_resource" "test_status" { depends_on = ["module.db.id"] #or any output variable provisioner "local-exec" { command = "script...
Terraform
49,641,484
11
I've been trying to create a terraform script for creating a cognito user pool and identity pool with a linked auth and unauth role, but I can't find a good example of doing this. Here is what I have so far: cognito.tf: resource "aws_cognito_user_pool" "pool" { name = "Sample User Pool" admin_create_user_co...
After messing around with this for a few days, i finally figured it out. I was merely getting confused with "Assume Role Policy" and "Policy". Once I had that sorted out, it worked. Here is (roughly) what I have now. I'll put it here in hopes that it will save someone trying to figure this out for the first time a...
Terraform
48,451,755
11
Let's say I've used Terraform to build my infrastructure and my tfstate gets deleted for some reason. This means I already have my resources defined in tf files, I just need to re-import everything. Does this have to be a manual process? For example this is how I import an EC2 instance: terraform import aws_instance.we...
No, there's no way to do this natively in Terraform; and even if you scripted a way together - I don't think it'd be very reliable and you wouldn't be able to trust that it selected the right resource (At least not easily). Terraform says multiple times in the documentation that you need to protect your state file; thi...
Terraform
47,613,926
11
I use Terraform to manage resources of Google Cloud Functions. But while the inital deployment of the cloud function worked, further deploments with changed cloud function source code (the source archive sourcecode.zip) were not redeployed when I use terraform apply after updating the source archive. The storage bucket...
You can append MD5 or SHA256 checksum of the content of zip to the bucket object's name. That will trigger recreation of cloud function whenever source code changes. ${data.archive_file.function_src.output_md5} data "archive_file" "function_src" { type = "zip" source_dir = "SOURCECODE_PATH/sourcecode" output_path = "...
Terraform
71,320,503
10
I am looking for a way to invalidate the CloudFront distribution cache using Terraform. I could not find any information in the docs. Is this possible and if so, how?
There is no in-built support within the aws_cloudfront_distribution or aws_cloudfront_cache_policy resource for cache invalidation. As a last resort, the local_exec provisioner can be used. Typically, from my experience, the cache is invalidated within the CI/CD pipeline using the AWS CLI create-invalidation command. ...
Terraform
69,794,727
10
I have an API Gateway setup using Terraform. I need to be able to visit the API Gateway on the base path, i.e, without the stage name appended to the base URL. https://{api_id}.execute-api.{region}.amazonaws.com/ <- acceptable https://{api_id}.execute-api.{region}.amazonaws.com/{StageName} <- not acceptable I would do ...
From the AWS documentation: You can create a $default stage that is served from the base of your API's URL—for example, https://{api_id}.execute-api.{region}.amazonaws.com/. You use this URL to invoke an API stage. The Terraform documentation doesn't mention this, but you can create a stage with $default as the stage...
Terraform
66,977,149
10
I'm creating 4 vms through count in azurerm_virtual_machine but i want to create only one public IP and associate it with the first VM ? is that possible if so how ? below is my template file resource "azurerm_network_interface" "nics" { count = 4 name = ... location = ... ...
Public IPs are created using azurerm_public_ip: resource "azurerm_public_ip" "public_ip" { name = "acceptanceTestPublicIp1" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location allocation_method = "Dynamic" } Having the address...
Terraform
65,935,259
10
I am trying to define a terraform output block that returns the ARN of a Lambda function. The Lambda is defined in a sub-module. According to the documentation it seems like the lambda should just have an ARN attribute already: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_functi...
Documentation is correct. Data source data.aws_lambda_function has arn attribute. However, you are trying to access the arn from a custom module module.aws_lambda_function. To do this you have to define output arn in your module. So in your module you should have something like this: data "aws_lambda_function" "existin...
Terraform
65,798,783
10
I'm having issues iterating over a list of objects within a template interpreted by the templatefile function. I have the following var: variable "destinations" { description = "A list of EML Channel Destinations." type = list(object({ id = string url = string })) } This is passed in to the templatefil...
I've just found (after crafting a small Terraform module to test templatefile output only) that the original config DOES work (at least in TF v0.12.29). The errors given are a bit of a Red Herring - the issue is to do with indentation within the template, e.g. instead of: Destinations: %{ for destination in destinati...
Terraform
64,651,270
10
When trying to create elb(classic load balancer) in AWS via terraform, I am sending a list of public subnet ids that were created from another module. In this case I have 4 subnets which are spanned across 3 az's. I have 2 subnets from az-1a when I am trying to run the terraform , I get an error saying same az can't be...
It sounds like this problem decomposes into two smaller problems: Determine the availability zone of each of the subnets. For each distinct availability zone, choose any one of the subnets that belongs to it. (I'm assuming here that there is no reason to prefer one subnet over another if both are in the same AZ.) For...
Terraform
63,727,252
10
A while ago I created a serverless Azure SQL resource in Terraform using the azurerm_sql_database block. Then in March, in azurerm version 2.3 they came out with the azurerm_mssql_database block, which as I understand is intended to replace azurerm_sql_database. I need to change the auto_pause_delay_in_minutes setting...
The old resource in Azure needs to be imported into the new resource definition in terraform. Then the old resource state in terraform needs remove. See the following walk through. Modify for whatever additional parameters you need, it is the same workflow. First build the azurerm_sql_database resource: # cat .\main.t...
Terraform
63,194,330
10
I tried to create an AWS security group with multiple inbound rules, Normally we need to multiple ingresses in the sg for multiple inbound rules. Instead of creating multiple ingress rules separately, I tried to create a list of ingress and so that I can easily reuse the module for different applications. PFB, module/s...
Thanks@apparentlymart, who helped to solve this in Terraform discussion The Security rule:- resource "aws_security_group_rule" "ingress_rules" { count = length(var.ingress_rules) type = "ingress" from_port = var.ingress_rules[count.index].from_port to_port = var.ingress_rules[cou...
Terraform
62,575,544
10
I have written a terraform configuration with variable definition like: variable "GOOGLE_CLOUD_REGION" { type = string } When I run terraform plan I am asked to fill in this variable even though this variable is set within my environment. Is there a way to tell terraform to work with current env vars? Or do I have t...
You can define the environment variable TF_VAR_GOOGLE_CLOUD_REGION to set that variable. If you are using bash, it might look like this: export TF_VAR_GOOGLE_CLOUD_REGION="$GOOGLE_CLOUD_REGION" terraform apply ... From Environment Variables under Configuration Language: Input Variables. As a fallback for the other wa...
Terraform
62,482,719
10
I'm trying to get tf 0.12.x new dynamic feature to work with a nested map, config is below. As you can see below (simplified for this) I'm defining all the variables and adding variable required_resource_access which contains a map. I was hoping to use new dynamic feature to create read this map in a nested dyanmic blo...
I had some time to test my comment... If I change the resource_access to a list it works. See code below: variable required_resource_access { type = list(object({ resource_app_id = string resource_access = list(object({ id = string type = string })) })) default = [{ resource_app_id ...
Terraform
62,221,306
10
I have a terraform file which fails when I run terraform plan and I get the error: Error: Cycle: module.hosting.data.template_file.bucket_policy, module.hosting.aws_s3_bucket.website It makes sense since the bucket refers to the policy and vice versa: data "template_file" "bucket_policy" { template = file("${path.mo...
You can use the aws_s3_bucket_policy resource. This allows you to create the resources without a circular dependency. This way, Terraform can: Create the bucket Create the template file, using the bucket ARN Create the policy, referring back to the template file and attaching it to the bucket. The code would look so...
Terraform
61,869,536
10
As the terraform azurerm provider misses support for azure webapp access restrictions (see github issue). We use a null_resource with local-exec to apply a access restriction: provisioner "local-exec" { command = <<COMMAND az webapp config access-restriction add --subscription ${self.triggers.subscription_...
I finally got this to work with the AzureCLI approach I described in the first post. I use addSpnToEnvironment (it adds the service provider credentials to the environment, as described in the documentation) and set the required parameters as described by terraform. - task: AzureCLI@2 displayName: "Terraf...
Terraform
61,268,776
10
Currently, I'm working on a requirement to make Terraform Tags for AWS resources more modular. In this instance, there will be one tag 'Function' that will be unique to each resource and the rest of the tags to be attached will apply to all resources. What I'm trying to do is combine the unique 'Function' value with ...
I tried to use map, it does work with new versions. The lines below works for me: tags = "${merge(var.resource_tags, {a="bb"})}"
Terraform
60,045,338
10
I created RDS instance using aws_db_instance (main.tf): resource "aws_db_instance" "default" { identifier = "${module.config.database["db_inst_name"]}" allocated_storage = 20 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class ...
You can use a provisioner (https://www.terraform.io/docs/provisioners/index.html) for that: resource "aws_db_instance" "default" { identifier = module.config.database["db_inst_name"] allocated_storage = 20 storage_type = "gp2" engine = "mysql" engine_version = "5.7" ...
Terraform
59,922,023
10
I have the following terraform module to setup app services under the same plan: provider "azurerm" { } variable "env" { type = string description = "The SDLC environment (qa, dev, prod, etc...)" } variable "appsvc_names" { type = list(string) description = "The names of the app services to create und...
So this is now possible since the v2.71 version of the Azure RM provider. A couple of things have to happen... Assign a Managed Identity to the application (can also use User Assigned but a bit more work) Set the site_config.acr_use_managed_identity_credentials property to true Grant the application's identity ACRPull...
Terraform
59,914,397
10
I'm trying to get terraform to add an "A" record to my dns zone in GCP. Efforts to do so result in an error: "update server is not set". A similar error is described here. So I gather from comments made there that I need an update item in my dns provider. Which I dutifully tried to provide. provider "dns" { update { ...
The dns provider is implementing the standard DNS update protocol defined in RFC 2136: Dynamic Updates in the Domain Name System, which tends to be implemented by self-hosted DNS server software like BIND. In that case, the credentials would be configured on the server side by the BIND operator and then you'd in turn p...
Terraform
59,759,132
10
I'm writing a terraform module which should be reused across different environments. In order to make things simple, here's a basic example of calling a module from one of the environments root module: ##QA-resources.tf module "some_module" { source = "./path/to/module" } some_variable = ${module.some_module.some...
In Terraform's view, every object is either managed by Terraform or not. Terraform avoids implicitly taking ownership of existing objects because if it were to do that then when you subsequently run terraform destroy you may end up inadvertently destroying something you didn't intend Terraform to be managing. In your c...
Terraform
58,891,274
10
I've tried to get all subnet ids to add aws batch with terraform with following code: data "aws_subnet_ids" "test_subnet_ids" { vpc_id = "default" } data "aws_subnet" "test_subnet" { count = "${length(data.aws_subnet_ids.test_subnet_ids.ids)}" id = "${tolist(data.aws_subnet_ids.test_subnet_ids.ids)[count.index...
"${data.aws_subnet.test_subnet.*.id}" is already string array type. you should input value without [ ] write code like : subnets = "${data.aws_subnet.test_subnet.*.id}" See : Here's A document about Resource: aws_batch_compute_environment
Terraform
58,404,831
10
I am trying to build multiple vnets in Azure using Terraform 0.12+ and its new for_each and running into some trouble. I was hoping that the new capabilities would allow me to create a generic network module that takes in a complex variable but I perhaps have reached its limit or am just not thinking it through correct...
Constructing this intermediate local.vnets map here is making this problem a little harder to solve, because it's throwing away all of the other information in those objects and thus making it hard to use that other information inside the resource "azurerm_virtual_network" "vnets" block. Instead, if we use repetition o...
Terraform
57,890,909
10
I use TerraForm as infrastructure framework in my application. Below is the configuration I use to deploy python code to lambda. It does three steps: 1. zip all dependencies and source code in a zip file; 2. upload the zipped file to s3 bucket; 3. deploy to lambda function. But what happens is the deploy command terraf...
You need to add dependency properly to achieve this, Otherwise, it will crash. First Zip the files # Zip the Lamda function on the fly data "archive_file" "source" { type = "zip" source_dir = "../lambda-functions/loadbalancer-to-es" output_path = "../lambda-functions/loadbalancer-to-es.zip" } then upload...
Terraform
57,145,037
10
Because of a timeout issue, terraform failed to create an ec2 instance. In order to recover from it I have manually removed the ec2 instance from aws console as well as the terraform state file. However now it tried to recreate + aws_iam_instance_profile.server id: <comp...
I couldn't find the instance profile in the IAM section in the console as described by Slushysnowman. This solved my issue: aws iam delete-instance-profile --instance-profile-name 'your-profile-name'
Terraform
56,931,561
10
I'm trying to create an RDS Cluster Aurora-MySQL with one instance in it. I get this error: "InvalidParameterValue: The engine mode provisioned you requested is currently unavailable" I tried using "serverless" and get the same error. Region: Ireland (eu-west-1) Any suggestions?
This error is also encountered when incorrectly trying to configure a serverless v2 configuration. It's a bit unintuitive, but engine_mode = "serverless" works for v1 and engine_mode = "provisioned" is required for v2. To ensure that you have a serverless v2 cluster you need: engine_mode = "provisioned" instance_class ...
Terraform
56,626,196
10
I'm creating a Kubernetes Service Account using terraform and trying to output the token from the Kubernetes Secret that it creates. resource "kubernetes_service_account" "ci" { metadata { name = "ci" } } data "kubernetes_secret" "ci" { metadata { name = "${kubernetes_service_account.ci.default_secret_na...
This works: resource "kubernetes_service_account" "ci" { metadata { name = "ci" } } data "kubernetes_secret" "ci" { metadata { name = kubernetes_service_account.ci.default_secret_name } } output "ci_token" { sensitive = true value = lookup(data.kubernetes_secret.ci.data, "token") }
Terraform
56,080,359
10
I'm confused as to how I should use terraform to connect Athena to my Glue Catalog database. I use resource "aws_glue_catalog_database" "catalog_database" { name = "${var.glue_db_name}" } resource "aws_glue_crawler" "datalake_crawler" { database_name = "${var.glue_db_name}" name = "${var.crawler_...
Our current basic setup for having Glue crawl one S3 bucket and create/update a table in a Glue DB, which can then be queried in Athena, looks like this: Crawler role and role policy: The assume_role_policy of the IAM role needs only Glue as principal The IAM role policy allows actions for Glue, S3, and logs The Glue...
Terraform
55,129,035
10
When you look at terraform's docs for security group, you can see that there is an option to define a security_groups argument inside the ingress/egress security rules. It seems quite strange to me, but maybe I'm missing something here. I saw this post but there are no real world use cases mentioned. My question is: In...
You can use this syntax to apply those ingress/egress rules to any infrastructure that belongs to a particular security group. This Terraform code, for example: ingress { from_port = "80" to_port = "80" protocol = "tcp" security_groups = [ "${aws_security_group.elb_sg.id}", ] } will allow...
Terraform
55,032,506
10
is there a possibility to add a sql user to the azure sql via terraform? https://www.mssqltips.com/sqlservertip/5242/adding-users-to-azure-sql-databases/ Or is there a better suggestions how to create a SQL user? Thanks
Yes you can do it from Terraform if that is what you want to happen. I would use a null resource provider in Terraform to execute the commands from the box that is running Terraform. You could use PowerShell, CMD, etc. to connect to the database after it is created and create your user account. Here is an example of ho...
Terraform
54,326,033
10
When I try to enable a private IP on my Cloud SQL instance (Postgresql 9.6) I get the follwoing error message: Network association failed due to the following error: set Service Networking service account as servicenetworking.serviceAgent role on consumer project I have a VPC which I select in the "Associated Network" ...
The Terraform code to create a Cloud SQL instance with Private IP has some errors. The first one is that the ${google_compute_network.private_network.self_link} variable get the entire name of the network, that means that will be something like www.googleapis.com/compute/v1/projects/PROJECT-ID/global/networks/testnw2. ...
Terraform
54,278,828
10
I have the following deploy.tf file: provider "aws" { region = "us-east-1" } provider "aws" { alias = "us_west_1" region = "us-west-2" } resource "aws_us_east_1" "my_test" { # provider = "aws.us_east_1" count = 1 ami = "ami-0820..." instance_type ...
Yes it can be used to create resources in different regions even inside just one file. There is no need to use modules for your test scenario. Your error is caused by a typo probably. If you want to launch an ec2 instance the resource you wanna create is aws_instance and not aws_us_west_1 or aws_us_east_1. Sure enough...
Terraform
53,981,403
10
In my main.tf I have the following: data "template_file" "lambda_script_temp_file" { template = "${file("../../../fn/lambda_script.py")}" } data "template_file" "library_temp_file" { template = "${file("../../../library.py")}" } data "template_file" "init_temp_file" { template = "${file("../../../__init__.py")}...
I resolved the issue by adding the following line the resource definition: source_code_hash = "${data.archive_file.lambda_resources_zip.output_base64sha256}" when the source files are modified, the hashed value will change and trigger the source file to be updated.
Terraform
53,477,485
10
I'm trying to set up Terraform for use with GCP and I'm having trouble creating a new project from the gcloud cli: Terraform Lab The command I'm using is gcloud projects create testproject The error I get over and over is: ERROR: (gcloud.projects.create) Project creation failed. The project ID you specified is already...
Project IDs are unique across all projects. That means if any user ever had a project with that ID, you cannot use it. testproject is pretty common, so it's not surprising it's already taken. Try a more unique ID. One common technique is to user your organization's name as a prefix.
Terraform
52,561,383
10
So I have an application that runs terraform apply in a directory, then can also run terraform destroy. I was testing the application, and I accidentally interrupted the processes while running apply Now it seems to be stuck with a partially created instance, where it recognizes the name of my instance I was creating/...
I'm afraid that the only option is by doing: execute terraform state rm RESOURCE example: terraform state rm aws_ebs_volume.volume. Manually remove the resource from your cloud provider.
Terraform
50,127,327
10
I'm using Terraform to provision some resources on AWS. Running the "plan" step of Terraform fails with the following vague error (for example): Error: Error loading state: AccessDenied: Access Denied status code: 403, request id: ABCDEF12345678, host id: SOMELONGBASE64LOOKINGSTRING=== Given a request id and a...
Terraform won't have any privileged information about the access denial, but AWS does. Because you mentioned S3 was the problem I based my answer on finding the S3 request id. You have a couple options to find the request given a request id in AWS. Create a trail in AWS CloudTrail. CloudTrail will log the API calls (...
Terraform
49,517,645
10
I have the following Terraform resource for configuring an Azure app service: resource "azurerm_app_service" "app_service" { name = "Test-App-Service-3479112" location = "${azurerm_resource_group.resource_group.location}" resource_group_name = "${azurerm_resource_group.resource_group.nam...
All, This is now available here: https://www.terraform.io/docs/providers/azurerm/r/app_service.html#cors And here is my example: resource "azurerm_app_service" "my-app" { name = "${var.api_name}" location = "${var.location}" resource_group_name = "${var.resource_group}" app_service_pl...
Terraform
47,718,205
10
I need to create several new EC2, RDS, etc.using Terraform, in an existing AWS VPC. and the existing subnet, security group, iam, etc. they are not created by Terraform. it is created manually. I heard the right way is to use terraform import (it is correct?). To test how terraform import works, I first tested how to i...
You can leave the body of the resource blank during the import, but you'll need to go back in and fill in the specific details once it's been imported. You can look at the imported resource with the terraform show command, and fill in all of the resource details, so when you try to run terraform plan it should show no...
Terraform
47,665,428
10
I've followed an excellent guide (Serverless Stack) that creates a typical CRUD serverless infrastructure with a react frontend. It's using the Serverless Framework for AWS. What I don't like is that to bootstrap the setup, there is a lot of manual clicking in GUIs (mostly Amazon's console interface) involved. I.e. the...
I agree that documentation on this would make an excellent pull request here. You're correct that serverless is using CloudFormation under the hood. The framework does expose the underlying CloudFormation machinery to you, by way of the resources key of your serverless.yml. I think the intent of the framework is that ...
Terraform
46,861,678
10
I have the need to create and manage multiple customer environments in AWS and I'm wanting to leverage Terraform to deploy all of the necessary resources. Each customer environment is basically the same with the exception of the URL they use to access one of the servers. I have put together a Terraform configuration t...
You should modulerize your code, then you can easily reuse that module(from a git repository) with different variables to be used for that customer. In this case for each customer, you will end up with only a file that configures the main module. Have one directory for each customer, with a terraform file that loads up...
Terraform
46,266,357
10
I am new to Terraform and I ran into some issue when trying to use environment variables with .tf file, I tried to use terraform.tfvars / variables.tf. ./terraform apply -var-file="terraform.tfvars" Failed to load root config module: Error parsing variables.tf: At 54:17: illegal char What am I missing here? Terraform ...
The aws_amis variable being used as a lookup map looks incorrectly formatted to me. Instead it should probably be of the format: variable "aws_amis" { default = { us-east-1 = "ami-49c9295f" eu-west-1 = "ami-49c9295f" us-west-1 = "ami-49c9295f" us-west-2 = "ami-49c9295f" } } As a...
Terraform
43,392,090
10
Scenario: I am running an AWS autoscaling group (ASG), and I have changed the associated launch configuration during terraform apply. The ASG stays unaffected. How do I recreate now the instances in that ASG (i.e., replace them one-by-one to do a rolling replace), which then is based on the changed/new launch configur...
The normal thing to do here is to use Terraform's lifecycle management to force it to create new resources before destroying the old ones. In this case you might set your launch configuration and autoscaling group up something like this: resource "aws_launch_configuration" "as_conf" { name_prefix = "terraform-lc-ex...
Terraform
39,345,609
10
I want to create 2 VPC security groups. One for the Bastion host of the VPC and one for the Private subnet. # BASTION # resource "aws_security_group" "VPC-BastionSG" { name = "VPC-BastionSG" description = "The sec group for the Bastion instance" vpc_id = "aws_vpc.VPC.id" ingress { from_port...
Terraform attempts to build a dependency chain for all of the resources defined in the folder that it is working on. Doing this enables it to work out if it needs to build things in a specific order and is pretty key to how it all works. Your example is going to fail because you have a cyclic dependency (as Terraform h...
Terraform
38,246,326
10
I have an drawing app for Android and I am currently trying to add a real eraser to it. Before, I had just used white paint for an eraser, but that won't do anymore since now I allow background colors and images. I do this by having an image view underneath my transparent canvas. The problem that I am facing is that w...
I could suggest you to read the official sample of FingerPaint.java It exactly matches what you are trying to achieve here. To not show the trail when you erase content, take a look at the onDraw() method and the eraserMode variable: @Override protected void onDraw(Canvas canvas) { canvas.drawColor(0xFFAAAAAA); ...
Eraser
25,094,845
19
My pipelines and schedulers were running smoothly without any problems. After I went out to lunch, I changed the number of epochs a Neural Network would run, save the .yaml file again and leave it in the bucket named "budgetff". Afterwards, everything stopped working. There are the errors and I have 0 clue as to how ...
The cause is that the latest version of requests does not support urllib3 2.0.0. This is fixed in kfp-2.0.0b16 (see PR with the change), so you can either upgrade to that, or create a new image that downgrades urllib. Maybe this is triggered by versions of requests-toolbelt and/or urllib3 that were both released in the...
Kubeflow
76,175,487
37
While running kubeflow pipeline having code that uses tensorflow 2.0. below error is displayed at end of each epoch W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Cancelled: Operation was cancelled Also, after some epochs, it does not show log and...
In my case, I didn't match the batch_size and steps_per_epoch For example, his = Test_model.fit_generator(datagen.flow(trainrancrop_images, trainrancrop_labels, batch_size=batchsize), steps_per_epoch=len(trainrancrop_images)/batchsize, validation_data=(test_...
Kubeflow
60,000,573
18
I'm exploring Kubeflow as an option to deploy and connect various components of a typical ML pipeline. I'm using docker containers as Kubeflow components and so far I've been unable to successfully use ContainerOp.file_outputs object to pass results between components. Based on my understanding of the feature, creating...
Files created in one Kubeflow pipeline component are local to the container. To reference it in the subsequent steps, you would need to pass it as: data_preprocessor = dsl.ContainerOp( name='data preprocessor', image='eu.gcr.io/kubeflow-demo-254012/data-preprocessor', arguments=["--fetched_datas...
Kubeflow
58,150,368
11
I am trying to find when it makes sense to create your own Kubeflow MLOps platform: If you are Tensorflow only shop, do you still need Kubeflow? Why not TFX only? Orchestration can be done with Airflow. Why use Kubeflow if all you are using scikit-learn as it does not support GPU, distributed training anyways? Orchest...
Building an MLOps platform is an action companies take in order to accelerate and manage the workflow of their data scientists in production. This workflow is reflected in ML pipelines, and includes the 3 main tasks of feature engineering, training and serving. Feature engineering and model training are tasks which req...
Kubeflow
60,787,646
11
That simple. Moving my layout into a fluid territory, working on scalable images. Using the img tag and setting max-width to 100% works perfectly, but i'd rather use a div with the image set as its background. The issue I'm running into is that the image doesn't scale to the size of the div it's in the background of. A...
As thirtydot said, you can use the CSS3 background-size syntax: For example: -o-background-size:35% auto; -webkit-background-size:35% auto; -moz-background-size:35% auto; background-size:35% auto; However, as also stated by thirtydot, this does not work in IE6, 7 and 8. See the following links for more information ab...
Fluid
6,300,749
59
I'm trying to create an optional foreign key using Entity Framework 7 and the Fluent-API. In EF v6.x we had the option to add this using .WithOptional or .HasOptional, but I cant find any equivalent functionality in EF 7.. any ideas? Br, Inx
Found the answer.. you can pass in "false" as a parameter to .IsRequired().. For instance: EntityShortcut<ContentEntity>() .HasMany(e => e.Children) .WithOne(e => e.Parent) .IsRequired(); That would be an requried relation EntityShortcut<ContentEntity>() ...
Fluid
34,578,981
20
I've noticed in my own work that 3 fluid columns fill out their parent element much better when their widths are set to 33.333% as opposed to just 33%. I've also noticed when researching various CSS frameworks (i.e. bootstrap.css) that they have 14 decimal places specified on their column widths! That seems like it wou...
It is required in some cases. I'm working on a site using the Twitter Bootstrap which has 6 divs stretching the full width of the site. If I just make the width of each one 16.66% a noticeable gap is left at the end, if I make the width 16.67% one of the divs is pushed onto the line below. This meant to get the divs to...
Fluid
14,364,485
19
I am trying to write the following if condition in fluid but it is not working as I would hope. Condition As part of a for loop I want to check if the item is the first one or 4th, 8th etc I would have thought the following would work but it display the code for every iteration. <f:if condition="{logoIterator.isFirst} ...
TYPO3 v8 Updated the answer for TYPO3 v8. This is quoted from Claus answer below: Updating this information with current situation: On TYPO3v8 and later, the following syntax is supported which fits perfectly with your use case: <f:if condition="{logoIterator.isFirst}"> <f:then>First</f:then> <f:else if="{lo...
Fluid
19,731,150
16
Below you see the debug for an object of type FileReference in fluid. In fluid the debug looks like this: <f:debug>{fileReference}</f:debug> The question is how do I access the properties highlighted in green, being width, height, and hovertext. The original file is an image, so width & height are default T3 properties...
The f:debug shows something similar to the var_dump function, so the properties of an object. In fluid you can only access the getter functions or if it is an array the values of the array. So if you write something like {fileReference.mergedProperties} the method getMergedProperties() is called if it is present. Knowi...
Fluid
40,135,241
15
Just need help as I have been trying sort this out for ages now. What I need: I've got a 2 column layout, where the left column has a fixed width 220px and the right column has a fluid width. Code is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...
Here's your altered CSS: html, body { background: #ccc; } .wrap { margin: 20px; padding: 20px; padding-right:240px; background: #fff; overflow:hidden; } .main { margin: 0 -220px 0 auto; width: 100%; float:right; } .sidebar { width: 200px; float: left; height: 200px; } ...
Fluid
6,797,172
12
Is it possible to get the current language key (or code) in a TYPO3 Fluid template? In the meantime I've found another solution using a view helper found here: <?php class Tx_AboUnitReservation_ViewHelpers_LanguageViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper { /** * Get the current langua...
Another solution using TypoScript object in Fluid template: # German language temp.language = TEXT temp.language.value = at # English language [globalVar = GP:L = 1] temp.language.value = en [global] lib.language < temp.language And Fluid code: <f:if condition="{f:cObject(typoscriptObjectPath: 'lib.language')} == ...
Fluid
10,446,432
12
For a project I'm using Typo3 v6.0. I'm looking to create nested content elements, or a content element container. I want to be able to create an inline two-column layout without using a specific template for it. I'm looking to do this without the use of templavoila. Extensions I have tried are gridelements, kb_nescefe...
I'm the author of the Fluid extension suite (flux, fluidcontent, fluidpages etc.) and would of course like to help you learn about using FluidContent to make FCEs. It's really not as advanced as one might fear. At the very least, it's much more compact than the example above. The following achieves the same result as y...
Fluid
15,156,751
11
In TYPO3 6.x, what is an easy way to quickly create custom content elements? A typical example (Maybe for a collection of testimonials): In the backend (with adequate labels): An image An input field A textarea When rendering: Image resized to xy input wrapped in h2 textarea passed through parseFunc and wrapped in m...
That scaring domain modeling stuff is probably best option for you :) Create an extension with FE plugin which holds and displays data as you want, so you can place it as a "Insert plugin". It's possible to add this plugin as a custom CType and I will find a sample for you, but little bit later. Note, you don't need to...
Fluid
18,464,356
11