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

feat(synthetics): add vpc configuration #18447

Merged
merged 24 commits into from
Mar 15, 2022

Conversation

RichiCoder1
Copy link
Contributor

@RichiCoder1 RichiCoder1 commented Jan 14, 2022

This PR adds vpc support to synthetics and is a continuation of #11865.

See Running a canary on a vpc.

Fixes #9954


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

This PR is a continuation of aws#11865 with the intention of filling out the remaining RunConfig values as well as adding missing VpcConfig properties.

I wasn't sure whether VPC settings should be top level (like Lambda) or in their own configuration object, so I made them seperate for now.
@gitpod-io
Copy link

gitpod-io bot commented Jan 14, 2022

@github-actions github-actions bot added the @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics label Jan 14, 2022
@RichiCoder1 RichiCoder1 marked this pull request as ready for review January 16, 2022 02:18
@kaizencc
Copy link
Contributor

Hi @RichiCoder1, thanks for opening this PR! As a first step, lets split this into two PRs, one for runConfig and one for vpcConfig. Specifically for runConfig, can you tell me the value add for exposing the rest of those properties over just using escape hatches? I don't see much of a use case for them and we're certainly not blocking anyone. That's why I didn't implement them in the L2 and I don't see anyone knocking down the door for them (the way they were for environment variables). vpcConfig might be helpful, but also might be harder to get right.

@RichiCoder1
Copy link
Contributor Author

RichiCoder1 commented Jan 24, 2022

Specifically for runConfig, can you tell me the value add for exposing the rest of those properties over just using escape hatches? I don't see much of a use case for them and we're certainly not blocking anyone. That's why I didn't implement them in the L2 and I don't see anyone knocking down the door for them (the way they were for environment variables)

Partially completeness, partially convenience. I'm personally using the timeout and tracing properties, and while "normal" it's weird to drop the Cfn just to set them when they're simple to implement (and Duration/Size are much nicer to work with).

As a first step, lets split this into two PRs, one for runConfig and one for vpcConfig

I probably should have seen this ask coming, I'll see what I can do :). Before I do so, do we want the VPC configuration options to be top level options, or a sub config like I have in this PR?

@kaizencc
Copy link
Contributor

I don't think its partially complete -- environment variables is its own thing separate from timeout and tracing. The canary L2 is not simply a shell for the L1 and we do not need to adhere to how cfn clusters properties; this means that supplying env variables in the L2 is visible at the top level. But sure, I hear your point that its low-hanging fruit and Duration/Size is better to work with. Happy to add them.

For vpcConfig, I think we should expose a property vpc: ec2.IVpc similar to what we do in lambda.

@kaizencc kaizencc removed their assignment Feb 3, 2022
@RichiCoder1 RichiCoder1 changed the title feat(aws-synthetics): complete runConfig and add vpcConfig feat(aws-synthetics): add vpc configuration Feb 25, 2022
@RichiCoder1
Copy link
Contributor Author

Sorry for taking so long to circle back around on this. Gonna scope it back down to VPC (current biggest pain point IMHO) and then can do a follow up on Run Config props.

@RichiCoder1
Copy link
Contributor Author

This is should be good to review now!

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Hi @RichiCoder1! Thanks for the PR - it looks like a great start. I don't have much experience with vpcs, so I'm hoping we can lean on your context to provide the best possible experience for our users.

packages/@aws-cdk/aws-synthetics/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-synthetics/README.md Outdated Show resolved Hide resolved
Comment on lines 401 to 402
* Returns a canary schedule object
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably should go back to the way it was

@@ -69,4 +70,15 @@ new synthetics.Canary(stack, 'MyPythonCanary', {
runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0,
});

const vpc = new ec2.Vpc(stack, 'MyVpc', { maxAzs: 2 });
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this in a new integ test file called integ.vpc-canary.ts. If you can come up with stack verification steps that would be great too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. For stack verification, do mean something like checking the underlying Lambda is in a VPC, or simulate some sort of VPC-only scenario?

Copy link
Contributor

Choose a reason for hiding this comment

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

best if we can check underlying lambda is in vpc, if possible. i don't actually know how.

@@ -499,6 +499,7 @@
"./aws-iotthingsgraph": "./aws-iotthingsgraph/index.js",
"./aws-iotwireless": "./aws-iotwireless/index.js",
"./aws-ivs": "./aws-ivs/index.js",
"./aws-kafkaconnect": "./aws-kafkaconnect/index.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

whats this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, don't know how I missed this. Might have been added by some tooling or a bad merge. I'll strip it out and see if it comes back

packages/@aws-cdk/aws-synthetics/lib/canary.ts Outdated Show resolved Hide resolved
Co-authored-by: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com>
@mergify mergify bot dismissed kaizencc’s stale review March 4, 2022 20:30

Pull request has been modified.

@kaizencc kaizencc added pr/do-not-merge This PR should not be merged at this time. and removed @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics labels Mar 11, 2022
@kaizencc kaizencc changed the title feat(aws-synthetics): add vpc configuration feat(synthetics): add vpc configuration Mar 11, 2022
@github-actions github-actions bot added the @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics label Mar 11, 2022
kaizencc
kaizencc previously approved these changes Mar 11, 2022
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Looks good to me @RichiCoder1. Approved, though I am going to wait on a second pair of eyes before we get this merged.

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

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

@RichiCoder1 just a couple of comments, the main one around implementing IConnectable.

Since the Canary class can now have security groups, it should implement ec2.IConnectable

export class Canary extends cdk.Resource implements ec2.IConnectable {

*
* @default false
*/
readonly allowPrivateSubnet?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed. I think it should be fine to just add this to the documentation in the readme and the vpcSubnets docstring. Users will specify if they want to place it in isolated subnets via the vpcSubnets prop, asking again here feels like a "are you sure you know what you are doing?" and I don't think that is needed.

@RichiCoder1
Copy link
Contributor Author

Nuked allowPrivateSubnet and added IConnectable! Let me know if that looks good and the implementation looks appropriate @corymhall.

@mergify mergify bot dismissed stale reviews from kaizencc and corymhall March 14, 2022 20:44

Pull request has been modified.

@RichiCoder1
Copy link
Contributor Author

RichiCoder1 commented Mar 14, 2022

Nuked allowPrivateSubnet and added IConnectable! Let me know if that looks good and the implementation looks appropriate @corymhall. Implementation more or less swiped from Lambda with wording tweaks (and a slightly variance in how security groups are appended)

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

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

Just 1 more comment and then we are good to go!

environmentVariables: props.environmentVariables,
vpcId: props.vpc.vpcId,
subnetIds,
securityGroupIds: securityGroups.map(sg => sg.securityGroupId),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should pull the list of security groups from this.connections since users will be able to modify this connections object.

securityGroupIds: Lazy.listValue({ produce: () => this.connections.securityGroups.map(sg => sg.securityGroupId) }),

Copy link
Contributor Author

@RichiCoder1 RichiCoder1 Mar 15, 2022

Choose a reason for hiding this comment

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

@corymhall Done! Though used Lazy.list as I got a warning that listValue was deprecated and that seemed to be the replacement. Good to know too, I was wondering how this sort of lazy evaluation worked!

@mergify mergify bot dismissed corymhall’s stale review March 15, 2022 15:55

Pull request has been modified.

corymhall
corymhall previously approved these changes Mar 15, 2022
@corymhall corymhall requested a review from kaizencc March 15, 2022 17:26
@mergify mergify bot dismissed corymhall’s stale review March 15, 2022 18:05

Pull request has been modified.

Copy link
Contributor

@kaizencc kaizencc 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 @RichiCoder1. Thanks for the contribution!

@kaizencc kaizencc removed the pr/do-not-merge This PR should not be merged at this time. label Mar 15, 2022
@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2a38371
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit c991e92 into aws:master Mar 15, 2022
@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@RichiCoder1 RichiCoder1 deleted the aws-synthetic-runconfig-and-vpc branch March 15, 2022 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[synthetics] Make it possible to set vpcConfig in synthetics.Canary for vpc private API testing
5 participants