Skip to content

feat: Allow adding VPC flow logs in environments#4088

Merged
mergify[bot] merged 10 commits intoaws:mainlinefrom
KollaAdithya:flowlog
Oct 19, 2022
Merged

feat: Allow adding VPC flow logs in environments#4088
mergify[bot] merged 10 commits intoaws:mainlinefrom
KollaAdithya:flowlog

Conversation

@KollaAdithya
Copy link
Copy Markdown
Contributor

@KollaAdithya KollaAdithya commented Oct 13, 2022

This PR solves #3721

  • Added a flow_logs field to Environment manifest
  • When the flow_logs is set to on then Cloud formation is going to create a FlowLog to capture information about the IP traffic going to and from network interfaces in your VPC.
  • For Example, if the Environment Manifest contains
  • Default VPC

network:
  vpc:
    flow_logs: on
  • Imported VPC

network:
  vpc:
    id: 'vpc-12345'
    subnets:
      public:
        - id: 'subnet-11111'
        - id: 'subnet-22222'
      private:
        - id: 'subnet-33333'
        - id: 'subnet-44444’
    flow_logs: on
  • Configured VPC

network:
  vpc:
      cidr: '10.0.0.0/16'
      subnets:
        public:
          - cidr: '10.0.0.0/24'
            az: 'us-east-2a'
          - cidr: '10.0.1.0/24'
            az: 'us-east-2b'
        private:
          - cidr: '10.0.3.0/24'
            az: 'us-east-2a'
          - cidr: '10.0.4.0/24'
            az: 'us-east-2b'
    flow_logs: on
  • In all the cases with flow_logs: on creates a FlowLog with name AppName-EnvironmentName-FlowLogGroup that enables you to capture information about the IP traffic going to and from network interfaces in your VPC.
  • It also creates an IAM Role to grant access for AWS EC2 to publish Flow logs to CloudWatch Logs.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@KollaAdithya KollaAdithya requested a review from a team as a code owner October 13, 2022 23:42
@KollaAdithya KollaAdithya requested review from paragbhingre and removed request for a team October 13, 2022 23:42
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 13, 2022

Codecov Report

Merging #4088 (4cc8243) into mainline (08983f7) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##           mainline    #4088      +/-   ##
============================================
+ Coverage     69.16%   69.18%   +0.01%     
============================================
  Files           248      248              
  Lines         35606    35610       +4     
  Branches        264      264              
============================================
+ Hits          24628    24635       +7     
+ Misses         9783     9781       -2     
+ Partials       1195     1194       -1     
Impacted Files Coverage Δ
internal/pkg/template/env.go 49.23% <ø> (ø)
internal/pkg/deploy/cloudformation/stack/env.go 72.04% <100.00%> (+0.08%) ⬆️
internal/pkg/manifest/env.go 78.76% <100.00%> (ø)
...ternal/pkg/deploy/cloudformation/cloudformation.go 72.47% <0.00%> (-0.55%) ⬇️
internal/pkg/manifest/storage.go 93.58% <0.00%> (ø)
internal/pkg/template/workload.go 42.58% <0.00%> (ø)
...al/pkg/deploy/cloudformation/stack/transformers.go 77.07% <0.00%> (+0.02%) ⬆️
internal/pkg/manifest/validate.go 84.17% <0.00%> (+0.08%) ⬆️
internal/pkg/aws/sessions/errors.go 33.33% <0.00%> (+7.24%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Copy link
Copy Markdown
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

Can we also add integ test for this feature at https://github.com/aws/copilot-cli/blob/b8c21b1023d0c6c8fe9aa22b1917183a42b2192e/internal/pkg/deploy/cloudformation/stack/env_integration_test.go ? Also could you add an example to the PR description for what the VPC flow logs look like?

Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Copy link
Copy Markdown
Contributor

@dannyrandall dannyrandall left a comment

Choose a reason for hiding this comment

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

looks awesome!! just a couple of small things

Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/templates/environment/cf.yml Outdated
Comment thread internal/pkg/template/env.go Outdated
Copy link
Copy Markdown
Contributor

@dannyrandall dannyrandall left a comment

Choose a reason for hiding this comment

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

:shipit:

@mergify mergify Bot merged commit 4987908 into aws:mainline Oct 19, 2022
@KollaAdithya KollaAdithya deleted the flowlog branch February 7, 2023 01:59
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.

8 participants