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

Feature/BBL-440 | ci improvement #1

Merged
merged 18 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
729f946
BBL-440 | adding .gitallow to for aws git-secrets to allow acount IDs…
exequielrafaela Nov 13, 2020
49fc58e
BBL-440 | adding .gitallowed patterns
exequielrafaela Nov 13, 2020
f1124d0
BBL-440 | updating circleci config to run pre-commit format + tf-docs…
exequielrafaela Nov 13, 2020
6678aaf
BBL-440 | fixing circleci/config.yaml
exequielrafaela Nov 13, 2020
3f9b3a2
BBL-440 | fixing circleci/config.yaml
exequielrafaela Nov 13, 2020
40ff4fe
BBL-440 | fixing circleci/config.yaml paths
exequielrafaela Nov 13, 2020
9a3f292
BBL-440 | including makefile for tf-lint validation
exequielrafaela Nov 13, 2020
e317b4a
BBL-440 | testing slack orb int
exequielrafaela Nov 13, 2020
a0fee0e
BBL-440 | adding context to slack notify cmd
exequielrafaela Nov 13, 2020
658cb1f
BBL-440 | removing not necessary context
exequielrafaela Nov 13, 2020
0b84e52
BBL-440 | testing custom slack message
exequielrafaela Nov 13, 2020
aabebb6
BBL-440 | slack channel globally seted via context
exequielrafaela Nov 13, 2020
a75acfa
BBL-440 | explicitely setting tool-ci channel to circle slack notif
exequielrafaela Nov 13, 2020
b916380
BBL-440 | testing with single quotes
exequielrafaela Nov 13, 2020
add06df
BBL-440 | using default templates for notifications
exequielrafaela Nov 13, 2020
1934bfc
BBL-440 | testing slack notif orbs
exequielrafaela Nov 13, 2020
e68b9d6
BBL-440 | removing heroku notif because of permission errors
exequielrafaela Nov 13, 2020
62d725d
BBL-440 | rolling back to official circleci orb
exequielrafaela Nov 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

jobs:
#
# Test 1 & Test 2
# Automated Tests
#
test-static-code-and-linting:
machine:
Expand All @@ -26,8 +26,34 @@ jobs:
git update-index --assume-unchanged "Makefile"

- run:
name: Validate Terraform format
command: make format-check
name: test-dependencies
command: |
#
# Install pre-commit
pip install pre-commit
#
# Install terraform
sudo apt-get install unzip
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VER}/terraform_${TERRAFORM_VER}_linux_amd64.zip
unzip terraform_${TERRAFORM_VER}_linux_amd64.zip
sudo mv terraform /usr/local/bin/
terraform --version
#
# Install terraform-docs
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.10.1/terraform-docs-v0.10.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64
chmod +x ./terraform-docs
sudo mv ./terraform-docs /usr/local/bin/terraform-docs

- run:
name: test-terraform-format-and-docs-delegated-admin-mod
command: |
cd modules/delegated-admin && make pre-commit

- run:
name: test-terraform-format-and-docs-multiaccount-setup-mod
command: |
cd modules/multiaccount-setup && make pre-commit

- run:
name: Install awscli
Expand Down Expand Up @@ -55,9 +81,24 @@ jobs:
cp /home/circleci/.aws/config /home/circleci/.aws/bb/config

- run:
name: Lint Terraform code
command: make tflint-deep
name: test-terraform-linting-delegated-admin-mod
command: |
cd modules/delegated-admin && make tflint-deep

- run:
name: test-terraform-linting-multiaccount-setup-mod
command: |
cd modules/multiaccount-setup && make tflint-deep

- slack/notify:
event: fail
mentions: '@leverage-support'
template: basic_fail_1
Copy link
Contributor

Choose a reason for hiding this comment

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

@exequielrafaela Just curious, are these templates defined in CircleCI's project configuration?

Copy link
Member Author

Choose a reason for hiding this comment

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

channel: 'tools-ci'
- slack/notify:
event: pass
template: success_tagged_deploy_1
channel: 'tools-ci'

#
# Release
Expand Down Expand Up @@ -101,12 +142,23 @@ jobs:
echo "==============================================================================================="
fi

- slack/notify:
event: fail
mentions: '@leverage-support'
template: basic_fail_1
channel: 'tools-ci'
- slack/notify:
event: pass
template: success_tagged_deploy_1
channel: 'tools-ci'

#
# CircleCI orbs are open-source, shareable packages of parameterizable reusable
# configuration elements, including jobs, commands, and executors.
#
orbs:
sumologic: circleci/sumologic@1.0.6
slack: circleci/slack@4.1.1

#
# Jobs workflow
Expand Down
48 changes: 48 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# EditorConfig is awesome: https://EditorConfig.org

# we have to set line endings to LF for all bash scripts, otherwise, if you save
# a script on Windows, it would have CRLF line breaks, which doesn’t work on
# Linux. This is achieved by a combination of ‘.editorconfig’ defining how the
# code is displayed in a text editor, and ‘.gitatttributes’, which controls how
# the file is saved in source control.

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file && 2 space indentation
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

# Unix-style newlines with a newline ending every file && 2 space indentation
[*.sh]
end_of_line = lf
indent_style = space
indent_size = 2

# Unix-style newlines with a newline ending every file && 2 space indentation
[*.py]
end_of_line = lf
indent_style = space
indent_size = 2

[*.{tf,tfvars}]
indent_size = 2
indent_style = space

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

# Tab indentation && 2 space indentation
[Makefile]
tab_width = 2
indent_style = tab

[COMMIT_EDITMSG]
max_line_length = 0
3 changes: 3 additions & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/awslabs/git-secrets
*README.md
examples/configure-guardduty/main.tf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
!/.github
!*.gitkeep
!*.editorconfig
!*.pre-commit-config.yaml

# SSH keys #
############
Expand Down
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
default_language_version:
# force all unspecified python hooks to run python3
python: python3

repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: pretty-format-json
args:
- --autofix
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md

- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.43.0
hooks:
- id: terraform_fmt
- id: terraform_docs
2 changes: 1 addition & 1 deletion examples/configure-guardduty/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Configure GuardDuty: this is intended to be done from an account that has
# been designated to be a GuardDuty delegated admin.
#
#
# Important: since designating a GuardDuty delegated admin account automatically
# enables GuardDuty in that account, you will need to import
# "module.guardduty.aws_guardduty_detector.this" before you can properly use
Expand Down
1 change: 1 addition & 0 deletions modules/delegated-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ No requirements.
## Outputs

No output.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4 changes: 4 additions & 0 deletions modules/delegated-admin/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MAKEFILES_DIR := ../../@bin/makefiles

-include ${MAKEFILES_DIR}/terratest13/terratest13.mk
-include ${MAKEFILES_DIR}/terraform13/terraform13.mk
1 change: 1 addition & 0 deletions modules/multiaccount-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ No requirements.
## Outputs

No output.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4 changes: 4 additions & 0 deletions modules/multiaccount-setup/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MAKEFILES_DIR := ../../@bin/makefiles

-include ${MAKEFILES_DIR}/terratest13/terratest13.mk
-include ${MAKEFILES_DIR}/terraform13/terraform13.mk