-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from timmyeats/dev
Merge dev for new feature
- Loading branch information
Showing
17 changed files
with
385 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
# Dockerfile | ||
[{Dockerfile,Dockerfile.template.erb,Dockerfile.sample}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Batch Files | ||
[*.{cmd,bat}] | ||
end_of_line = crlf | ||
|
||
# Bash Files | ||
[*.sh] | ||
end_of_line = lf | ||
|
||
# tsv use tab to separate fields | ||
[*.tsv] | ||
indent_style = tab | ||
|
||
# Applies to all Markdown files | ||
[*.{md,mdx}] | ||
trim_trailing_whitespace = false | ||
|
||
# Matches multiple files with brace expansion notation | ||
# Set default charset | ||
[*.{js,py}] | ||
charset = utf-8 | ||
|
||
# Web Files | ||
[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}] | ||
indent_size = 2 | ||
|
||
# 4 space indentation | ||
[*.py] | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 79 | ||
|
||
# Tab indentation (no size specified) | ||
[Makefile] | ||
indent_style = tab | ||
|
||
# Indentation override for all JS under lib directory | ||
[lib/**.js] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# Matches the exact files either package.json or .travis.yml | ||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
default_language_version: | ||
python: python3.9 | ||
repos: | ||
# General | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: detect-aws-credentials | ||
args: [--allow-missing-credentials] | ||
- id: detect-private-key | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
- id: check-ast | ||
- id: check-case-conflict | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: check-symlinks | ||
- id: check-xml | ||
- id: destroyed-symlinks | ||
- id: end-of-file-fixer | ||
- id: check-byte-order-marker | ||
- id: mixed-line-ending | ||
- id: name-tests-test | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- repo: https://github.com/zricethezav/gitleaks | ||
rev: v8.18.1 | ||
hooks: | ||
- id: gitleaks | ||
|
||
# Python | ||
- repo: https://github.com/psf/black # Can choose between black or autopep8 | ||
rev: 24.1.1 | ||
hooks: | ||
- id: black | ||
args: [-t, py39] | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.15.0 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py39-plus] | ||
- repo: https://github.com/asottile/add-trailing-comma | ||
rev: v3.1.0 | ||
hooks: | ||
- id: add-trailing-comma | ||
- repo: https://github.com/asottile/reorder_python_imports | ||
rev: v3.1.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
|
||
# Terraform | ||
- repo: https://github.com/terraform-docs/terraform-docs | ||
rev: v0.17.0 | ||
hooks: | ||
- id: terraform-docs-go | ||
args: | ||
["markdown", "table", "--output-file", "README.md", "."] | ||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.86.0 | ||
hooks: | ||
- id: terraform_fmt | ||
args: [--args=-diff] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import boto3 | ||
|
||
from .taggers import changing_tag_to_array | ||
|
||
|
||
# Create tags for AWS resources | ||
def add_tags_in_resource(tags, resource): | ||
asg_converted_tags = [] | ||
converted_tags = changing_tag_to_array(tags) | ||
|
||
try: | ||
for tag in converted_tags: | ||
tag["ResourceId"] = resource | ||
tag["ResourceType"] = "auto-scaling-group" | ||
tag["PropagateAtLaunch"] = True | ||
asg_converted_tags.append(tag) | ||
client = boto3.client("autoscaling") | ||
response = client.create_or_update_tags(Tags=asg_converted_tags) | ||
except Exception as e: | ||
response = {"[LOG] Error: ": str(e)} | ||
|
||
return response, converted_tags | ||
|
||
|
||
def tagger(event, tags): | ||
request_parameters = event["detail"]["requestParameters"] | ||
autoscaling_group_name = request_parameters["autoScalingGroupName"] | ||
|
||
if autoscaling_group_name is not None: | ||
response, converted_tags = add_tags_in_resource(tags, autoscaling_group_name) | ||
response["autoscaling_group_name"] = autoscaling_group_name | ||
response["converted_tags"] = converted_tags | ||
return response | ||
|
||
else: | ||
return "[LOG] No resource id found!" |
Oops, something went wrong.