winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.05k stars 196 forks source link

tf-aws test iterations are broken #4073

Open skorfmann opened 1 year ago

skorfmann commented 1 year ago

I tried this:

specifying the rootId in combination with noClean, e.g.

wing test --rootId cors --no-clean -t tf-aws api_cors_custom.w

This happened:

...
One or more tests failed. Cleaning up resources...
Cleanup is disabled!
Output files available at /var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/-wing-compile-testCt2nrK/target/test/api_cors_custom.tfaws
Command failed: terraform apply -auto-approve
╷
│ Error: creating Lambda Function (cloud-Api-OnRequest-4045a5be-c81ba6c1): operation error Lambda: CreateFunction, https response error StatusCode: 409, RequestID: f6fed263-ec55-41f6-93aa-ce5d5a38ec98, ResourceConflictException: Function already exist: cloud-Api-OnRequest-4045a5be-c81ba6c1
│
│   with aws_lambda_function.cors_env0_cloudApi_cloudApi-OnRequest-4045a5be_919CC251,
│   on main.tf.json line 541, in resource.aws_lambda_function.cors_env0_cloudApi_cloudApi-OnRequest-4045a5be_919CC251:
│  541:       },
│
╵
╷
│ Error: creating Lambda Function (cloud-Api-OnRequest-370e3dee-c8729c00): operation error Lambda: CreateFunction, https response error StatusCode: 409, RequestID: c54c4528-0f80-4830-9c7a-50dba886c34c, ResourceConflictException: Function already exist: cloud-Api-OnRequest-370e3dee-c8729c00
│
│   with aws_lambda_function.cors_env1_cloudApi_cloudApi-OnRequest-370e3dee_D685A670,
│   on main.tf.json line 668, in resource.aws_lambda_function.cors_env1_cloudApi_cloudApi-OnRequest-370e3dee_D685A670:
│  668:       },
│
╵
╷
│ Error: creating Lambda Function (cloud-Api-OnRequest-841b8351-c881c372): operation error Lambda: CreateFunction, https response error StatusCode: 409, RequestID: 726727c8-090f-4d82-99ba-a2c4fdf150c9, ResourceConflictException: Function already exist: cloud-Api-OnRequest-841b8351-c881c372
│
│   with aws_lambda_function.cors_env2_cloudApi_cloudApi-OnRequest-841b8351_B3A45291,
│   on main.tf.json line 795, in resource.aws_lambda_function.cors_env2_cloudApi_cloudApi-OnRequest-841b8351_B3A45291:
│  795:       },
│
╵

Cleanup is disabled!
Output files available at /var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/-wing-compile-test9BZyl9/target/test/api_cors_custom.tfaws

the issue is, that the compile output directory differs between the two runs:

/var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/-wing-compile-testCt2nrK/target/test/api_cors_custom.tfaws
/var/folders/zl/z8nc41qs7010qsfngfc_z1zc0000gn/T/-wing-compile-test9BZyl9/target/test/api_cors_custom.tfaws

this leads to the fact, that the terraform state is not shared between the two runs and the lambda function is created twice.

I expected this:

Being able to iterate on tests without having to recreate all resources for each run.

Specifying noClean only would still recreate the application from scratch, that's why I thought adding the rootId flag might be helpful. I think what I actually would want is a flag like iterate or the noClean flag to behave like this.

Is there a workaround?

No response

Component

CLI

Wing Version

v0.29.0

Node.js Version

18.6.0

Platform(s)

MacOS

Anything else?

No response

Community Notes

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 8 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 5 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 2 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!