Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/synthetics_canary - new resource #13140

Merged
merged 67 commits into from
Feb 12, 2021

Conversation

DrFaust92
Copy link
Collaborator

@DrFaust92 DrFaust92 commented May 3, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #11145

Release note for CHANGELOG:

resource_aws_synthetics_canary: add new service

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSSyntheticsCanary_'
--- PASS: TestAccAWSSyntheticsCanary_tags (349.62s)
--- PASS: TestAccAWSSyntheticsCanary_disappears (146.87s)
--- PASS: TestAccAWSSyntheticsCanary_runConfig (213.57s)
--- PASS: TestAccAWSSyntheticsCanary_basic (86.61s)
--- PASS: TestAccAWSSyntheticsCanary_runtimeVersion (208.80s)
--- PASS: TestAccAWSSyntheticsCanary_runConfigTracing (208.81s)

@DrFaust92 DrFaust92 requested a review from a team May 3, 2020 20:15
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. dependencies Used to indicate dependency changes. provider Pertains to the provider itself, rather than any interaction with AWS. labels May 3, 2020
@DrFaust92 DrFaust92 mentioned this pull request May 3, 2020
@ghost ghost added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label May 3, 2020
@DrFaust92
Copy link
Collaborator Author

DrFaust92 commented May 4, 2020

basic use case test now passing

need to add the following:

  • more tests (VPC and other configs)
  • add logic to get code from s3 (only arguments are added)
  • wait for creation/update logic
  • wait for deletion logic

@DrFaust92
Copy link
Collaborator Author

DrFaust92 commented May 4, 2020

When a canary is deleted, the Lambda that is created by it is not deleted...
and when that is coupled with a VPC config there is an endless delete loop for VPC resources as the lambdas ENIs are also not deleted

a work around is to delete the function as well but it requires calling the lambda from the canary resource for a resource thats not managed by terraform (albeit it is a byproduct)

@bflad / @ewbankkit , thoughts?

edit: according to the docs, none of the resources created by the canary are destroyed automatically. so there is more junk from other services as well

@bflad
Copy link
Contributor

bflad commented May 6, 2020

@DrFaust92 sounds less than ideal. I think first things first we should split this PR into the service client and tagging parts (which we can merge immediately) versus the problematic resource implementation (which I'm not sure when we'll have more time to look into this issue).

@DrFaust92
Copy link
Collaborator Author

Will split these

@DrFaust92 DrFaust92 changed the title [WIP]r/synthetics_canary - new service [WIP]r/synthetics_canary - new resource May 6, 2020
@DrFaust92
Copy link
Collaborator Author

opened for only service and tag implementation #13186

@ghost ghost added the service/synthetics Issues and PRs that pertain to the synthetics service. label May 16, 2020
@tdmalone
Copy link
Contributor

for a resource thats not managed by terraform (albeit it is a byproduct)

@DrFaust92 This sounds similar - although admittedly, more complex - to eg. a CloudWatch log group being created the first time a Lambda is run and not being deleted when the Lambda is deleted. The general workaround for that with Terraform is to also define the log group, and ensure it's created before the function runs for the first time; the function then uses that log group and if you delete everything from Terraform, everything is deleted.

I haven't played around with Synthetics in anger yet so I'm not sure if a similar workflow would work (particularly given you probably wouldn't want to manage the entire Lambda from within Terraform... unless the code can be easily referenced from an S3 object? 🤔) but perhaps that workflow ^^ can offer inspiration towards a solution here.

@bflad bflad added new-resource Introduces a new resource. and removed dependencies Used to indicate dependency changes. needs-triage Waiting for first response or review from a maintainer. labels Jun 15, 2020
@immo-huneke-zuhlke
Copy link

I've used the temporary provider based on this pull request with good results. I'd be keen to see this merged ASAP because the temporary provider will not pass the security review before production release, being considered SOUP (software of unknown provenance). Any idea when it might happen?

@DrFaust92
Copy link
Collaborator Author

hey @immo-huneke-zuhlke, i wasn't looking at this lately but at the time i was having issues with canary resource deletion as there are resource that are implicitly created by canary and create annoying dependencies. if you are satisfied with a fork of this branch im guessing some changes were made to it.

i'll be happy receive a review of what changes are required to make this work or merge change from the fork.

@immo-huneke-zuhlke
Copy link

immo-huneke-zuhlke commented Jul 16, 2020 via email

@ewbankkit
Copy link
Contributor

@DrFaust92 I have been testing with what we have in this PR 👏 and it seems like once the Synthetics Canary has been created I can manually delete the Lambda that was implicitly created in the console. A terraform destroy of the in-VPC acceptance test configuration then completes cleanly.
The answer may then be to add an acceptance test step that deletes the lambda (there is a standard naming pattern documented).
There is still the problem that in a pure IaC world that lambda can't be deleted via this provider. The user will have to shell out to the AWS CLI or something.
As Amazon do, we could add the list of implicitly created resources to the documentation and even return the Lambda function and layer ARNs as Computed attributes.

@ghost ghost added the documentation Introduces or discusses updates to documentation. label Jul 18, 2020
@DrFaust92
Copy link
Collaborator Author

Added some docs regarding implicit resources + some added tests (disappears)
added support for setting memory for canary lambda.

still experimenting with lambda deletion but all else seems to be working after a few tweaks.

@MaksymBilenko
Copy link

I think that canary start option is missing here.

@DrFaust92
Copy link
Collaborator Author

@MaksymBilenko, not sure i want to mix canary execution and canary start in a single resource. id split it it of to a different data source maybe, like lambda execution.

@brntsllvn
Copy link

brntsllvn commented Aug 13, 2020

@DrFaust92 Looking at the PR, this looks mostly done...? I'm happy to beta test or contribute if that moves things forward. Let me know how I can assist. Thanks for your effort here.

@YakDriver YakDriver self-assigned this Feb 12, 2021
* `vpc_config` - (Optional) Configuration block. Detailed below.
* `zip_file` - (Optional) ZIP file that contains the script, if you input your canary script directly into the canary instead of referring to an S3 location. It can be up to 5 MB. **Conflicts with `s3_bucket`, `s3_key`, and `s3_version`.**

### schedule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the modern documentation has links on the right side of the page to all the sections, internal links to the subsections aren't needed.

Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🎉

GovCloud:

--- PASS: TestAccAWSSyntheticsCanary_disappears (36.45s)
--- PASS: TestAccAWSSyntheticsCanary_s3 (58.41s)
--- PASS: TestAccAWSSyntheticsCanary_runConfigTracing (86.62s)
--- PASS: TestAccAWSSyntheticsCanary_basic (92.23s)
--- PASS: TestAccAWSSyntheticsCanary_runtimeVersion (92.29s)
--- PASS: TestAccAWSSyntheticsCanary_tags (97.04s)
--- PASS: TestAccAWSSyntheticsCanary_runConfig (98.37s)
--- PASS: TestAccAWSSyntheticsCanary_startCanary (101.86s)
--- PASS: TestAccAWSSyntheticsCanary_vpc (477.29s)

us-west-2:





--- PASS: TestAccAWSSyntheticsCanary_basic (86.26s)
--- PASS: TestAccAWSSyntheticsCanary_disappears (40.82s)
--- PASS: TestAccAWSSyntheticsCanary_runConfig (80.27s)
--- PASS: TestAccAWSSyntheticsCanary_runConfigTracing (78.04s)
--- PASS: TestAccAWSSyntheticsCanary_runConfigTracing (80.96s)
--- PASS: TestAccAWSSyntheticsCanary_runtimeVersion (75.07s)
--- PASS: TestAccAWSSyntheticsCanary_s3 (45.80s)
--- PASS: TestAccAWSSyntheticsCanary_startCanary (92.94s)
--- PASS: TestAccAWSSyntheticsCanary_tags (76.34s)
--- PASS: TestAccAWSSyntheticsCanary_vpc (655.78s)

@YakDriver YakDriver modified the milestones: Roadmap, v3.28.0 Feb 12, 2021
@YakDriver YakDriver merged commit fca4014 into hashicorp:main Feb 12, 2021
@ghost
Copy link

ghost commented Feb 12, 2021

This has been released in version 3.28.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 14, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 14, 2021
@DrFaust92 DrFaust92 deleted the r/synthetics_new_service branch April 15, 2021 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/synthetics Issues and PRs that pertain to the synthetics service. size/XXL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudWatch Synthetics