Skip to content

Terraform performance with large number of resources #16375

@zeridon

Description

@zeridon

Hi Team,

I have the following configuration:

  • one VPC
  • 6 different networks inside the VPC
  • 2 nat gw
  • 36 opsworks stacks
  • 300 or so security groups
  • 1200 or opswork layers

In total about 1600 resources in my configs.

Creation of this whole config in aws took about 30 min - most of the time could probably be attributed to waiting and connection handling

Plan with a simple change (e.g. adding 6 new layers) takes around 8 min. Probably most of the time can be attributed to connection handling and waiting, but there is around a minute or so after the remote state is retrieved that terraform stands there doing magic.

Memory usage is 2+ GB

The state file i have (remotely stored in s3) is 8.6mb

Some quick observations:

2017/10/17 16:22:51 [INFO] command: backend initialized: *s3.Backend
2017/10/17 16:22:51 [DEBUG] [aws-sdk-go] DEBUG: Response s3/GetObject Details:
2017/10/17 16:22:54 [INFO] terraform: building graph: GraphTypeInput
2017-10-17T16:23:01.016+0300 [DEBUG] plugin: starting plugin: path=/home/zeridon/work/repos/cloud-infrastructure/region-terraform/.terraform/plugins/linux_amd64/terraform-provider-aws_v1.0.0_x4 args=[/home/zeridon/work/repos/cloud-infrastructure/region-terraform/.terraform/plugins/linux_amd64/terraform-provider-aws_v1.0.0_x4]
2017-10-17T16:23:21.446+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:21 [INFO] Building AWS region structure

I see also a large number of the following sequence (even from the start and not due to timeouts or exceeded limits).

2017-10-17T16:23:22.116+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:22 [DEBUG] [aws-sdk-go] DEBUG: Request sts/GetCallerIdentity Details:
2017-10-17T16:23:22.803+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:22 [DEBUG] [aws-sdk-go] DEBUG: Response sts/GetCallerIdentity Details:
2017-10-17T16:23:22.805+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:22 [DEBUG] [aws-sdk-go] DEBUG: Request iam/GetUser Details:
2017-10-17T16:23:23.554+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:23 [DEBUG] [aws-sdk-go] DEBUG: Response iam/GetUser Details:
2017-10-17T16:23:23.555+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:23 [DEBUG] [aws-sdk-go] DEBUG: Request ec2/DescribeAccountAttributes Details:
2017-10-17T16:23:24.208+0300 [DEBUG] plugin.terraform-provider-aws_v1.0.0_x4: 2017/10/17 16:23:24 [DEBUG] [aws-sdk-go] DEBUG: Response ec2/DescribeAccountAttributes Details:
$ egrep 'Response ec2/DescribeAccountAttributes' terraform-debug.log | wc -l
539

Usually NOT followed by anything that can be easily associated with a call to AWS api to retrieve some info.

The questions i have:

  • Is this memory usage expected
  • What is using this time after state download and can it be optimized (debug log can be provided)
  • The sequence descriped in the second code block repeats 10 times at a time (that corresponds to -parallelism=10) but why the auth info is not kept between invocations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions