Skip to content

feat(deploy): add env resources import/adjust#1204

Merged
mergify[bot] merged 6 commits intoaws:masterfrom
iamhopaul123:deploy/customized-vpc-resources
Aug 1, 2020
Merged

feat(deploy): add env resources import/adjust#1204
mergify[bot] merged 6 commits intoaws:masterfrom
iamhopaul123:deploy/customized-vpc-resources

Conversation

@iamhopaul123
Copy link
Copy Markdown
Contributor

part of #1192.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@iamhopaul123 iamhopaul123 requested a review from a team as a code owner July 28, 2020 23:14
@iamhopaul123 iamhopaul123 force-pushed the deploy/customized-vpc-resources branch from faf27ef to 85d87fb Compare July 28, 2020 23:15
Copy link
Copy Markdown
Contributor

@bvtujo bvtujo left a comment

Choose a reason for hiding this comment

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

This is super slick! Thank you so much for writing out the CF. Just to confirm there will be test cases for all these branching logic paths, right?

e.AdjustVpcConfig.PrivateSubnetCIDRs = aws.StringSlice(strings.Split(defaultPrivateSubnetCIDRS, ","))
}

content, err := e.parser.Parse(EnvTemplatePath, struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any reason we might want this to be its own defined struct? for reusability or ease of modifying the code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is for reusability and ease of extending the struct (by categorizing fields), since other than vpc resources we'll have more options available and if flattening those two it would be very long.

@iamhopaul123
Copy link
Copy Markdown
Contributor Author

This is super slick! Thank you so much for writing out the CF. Just to confirm there will be test cases for all these branching logic paths, right?

The main logic changes are in CFN template which will be included in e2e tests!

Copy link
Copy Markdown
Contributor

@efekarakus efekarakus left a comment

Choose a reason for hiding this comment

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

Awesomee

Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment thread internal/pkg/deploy/env.go Outdated
Comment thread internal/pkg/deploy/env.go Outdated
Comment thread internal/pkg/deploy/env.go Outdated
Comment thread internal/pkg/deploy/env.go Outdated
Comment thread templates/environment/cf.yml Outdated
Comment thread templates/environment/cf.yml Outdated
Comment thread templates/environment/cf.yml Outdated
@iamhopaul123 iamhopaul123 force-pushed the deploy/customized-vpc-resources branch from f8e2498 to 06c277d Compare July 29, 2020 22:13
Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment on lines +53 to +54
// ParseEnv parses an environment's CloudFormation template with the specified data object and returns its content.
func (t *Template) ParseEnv(data interface{}, options ...ParseOption) (*Content, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you look at these Parse* methods, we decided on purpose to take a specific struct so that we are guaranteed not to run into a runtime issue by forcing the data passed in to always render a valid template. For example:

func (t *Template) ParseLoadBalancedWebService(data ServiceOpts) (*Content, error) {

I think I made a mistake with having these defined as methods, instead what do you think of defining them as functions in this package. Here is a sample interface: https://gist.github.com/efekarakus/3edbd280587c8433b0811307c2027b6a with an explanation at the bottom.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me know your thoughts with the API above.
If you like it, we can keep the current PR as is but do have the next PR be a refactor of the template pkg.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah since this pr is already big enough. I'll do the refactoring in the next one!

Comment thread internal/pkg/template/env.go Outdated
Comment thread templates/environment/cf.yml
Comment thread templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/env.go Outdated
Comment thread internal/pkg/template/env.go Outdated
Comment thread internal/pkg/template/env.go Outdated
@iamhopaul123 iamhopaul123 force-pushed the deploy/customized-vpc-resources branch from 1d1947d to d5d1cae Compare July 31, 2020 17:55
Copy link
Copy Markdown
Contributor

@kohidave kohidave 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! A few comments. Did you run the integ tests, by chance?

Comment thread internal/pkg/template/env.go Outdated
Comment on lines +35 to +36
ImportVpc *ImportVpcOpts
VpcConfig *AdjustVpcOpts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you do me a favor and separate this into two structs

type EnvImport struct {
  VPC *ImportVPC
} 

type EnvConfig struct {
  VPC *ConfigVPC
}

I just want to make it way easier in the future to add new config/import options.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(We can even consider nesting them so we don't have to worry about namespacing them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

discussed offline and keep it as it is for now

Comment thread templates/environment/cf/cfn-execution-role.yml Outdated
Comment thread templates/environment/cf/vpc-resources.yml
@kohidave kohidave added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jul 31, 2020
@iamhopaul123 iamhopaul123 removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 1, 2020
@mergify mergify bot merged commit 850c3fb into aws:master Aug 1, 2020
Louise15926 pushed a commit to Louise15926/amazon-ecs-cli-v2 that referenced this pull request Aug 5, 2020
<!-- Provide summary of changes -->
part of aws#1192.
<!-- Issue number, if available. E.g. "Fixes aws#31", "Addresses aws#42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants