Skip to content

refactor: update code convention for file naming and change code to the desired state #284

@mglotov

Description

@mglotov

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

It's needed to choose 1 solution or several and update doc to make naming process as clear as possible
Possible solutions for layer1-aws:

  1. Group resources by type in layer1-aws (for example: all s3 buckets are described in aws-s3.tf, all security-groups in aws-sg.tf, etc). In this way it's very easy to find and update resources of the same type. However
    PROS:
    * it's very easy to find and update resources of the same type
    CONS:
    * It's difficult to identify what resources are created for one function (we created aws-eks-auth.tf, aws-kms.tf, aws-eks.tf files to provision EKS cluster)
    * If we have lots of buckets, it will be very difficult to find the necessary one without using search
  2. Use suffixes to identify type and function (for example: aws-s3-cloudtrail.tf, aws-sns-eventbridge.tf, aws-kms-eks.tf, where the first part after AWS is type of services and the second part is function or for what this s3 bucket or SNS topic are used)
    PROS:
    * it's clearer than in previous option where resource is used and how it's connected with others.
    CONS:
    * the more resources we have, the more difficult it's to manage large number of files.
  3. Use the same approach as we use for layer2-k8s, i.e. group resource by function/feature. For example, group all resources needed to provision EKS cluster in one file aws-eks.tf, group all resources needed to configure alerts based on CIS benchmark in one file aws-cis-benchmark-alerts.tf
    PROS:
    * the one approach is used for both layers
    * it's the easiest way to find all resources related to one function/feature
    CONS:
    * it sometimes can be unclear what resources are created without reading files (aws-cis-benchmark-alerts.tf)
    * it's difficult to update one type module version (module s3, module sg, etc)

Current Behavior

It isn't clear now what names to use for files in layer1-aws folder. There is a code convention with the next item https://github.com/maddevsio/aws-eks-base/blob/main/.github/CONTRIBUTING.md#names-of-terraform-files-directories-and-modules. However, it doesn't cover layer2-k8s, because we decided to use another approach to group resources there.
So, there are several ways how we group resources and name files (especially big difference between layer1-aws and layer2-k8s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions