-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add ami start and record lambda #112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
144402b
feat: add ami start and record lambda
dracarys18 317597f
feat: remove unnecessary import
dracarys18 c33a4bf
fix: permissions
dracarys18 f18caab
feat: add base image
dracarys18 00f8e0a
fix: start ib
dracarys18 744000b
fix: typo
dracarys18 a7083fa
feat: pass ami ids in cdk
dracarys18 a804e4f
fix: make instructions clear
dracarys18 9f86bb2
fix: add exit 1 in case of error
dracarys18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
name: InstallBase | ||
description: This document installs all required packages on top of Amazon Linux 2 | ||
schemaVersion: 1.0 | ||
|
||
phases: | ||
- name: build | ||
steps: | ||
- name: InstallBase | ||
action: ExecuteBash | ||
inputs: | ||
commands: | ||
- sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH | ||
- sudo echo -e "[wazuh]\ngpgcheck=1\ngpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages.wazuh.com/4.x/yum/\nprotect=1" >> /etc/yum.repos.d/wazuh.repo | ||
- WAZUH_MANAGER="10.0.0.2" sudo yum install -y wazuh-agent | ||
- sudo systemctl daemon-reload | ||
- sudo systemctl enable wazuh-agent | ||
- sudo systemctl start wazuh-agent | ||
- sudo sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo | ||
- sudo amazon-linux-extras install epel | ||
- sudo yum update -y | ||
- sudo yum install -y redis | ||
- sudo yum install -y postgresql14 | ||
- sudo yum install -y clamav freshclam clamav-update | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
from typing import Union | ||
import json | ||
import os | ||
import logging | ||
import boto3 | ||
logging.getLogger().setLevel(logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def lambda_handler(event, _): | ||
logger.info(event) | ||
|
||
message_body = event.get("Records")[0].get("Sns").get("Message") | ||
json_body = json.loads(message_body) | ||
ami = json_body["outputResources"]["amis"][0]["image"] | ||
ssm_key = os.environ["IMAGE_SSM_NAME"] | ||
logger.info(f"updating ssm {ssm_key}") | ||
ssm_client = boto3.client("ssm") | ||
try: | ||
result = ssm_client.put_parameter( | ||
Name=ssm_key, | ||
Value=ami, | ||
Type="String", | ||
DataType="text", | ||
Tier="Advanced", | ||
Overwrite=True, | ||
) | ||
logger.info(result) | ||
except Exception as e: | ||
logger.error(e) | ||
|
||
return create_response(200, {}) | ||
|
||
|
||
def create_response(code: int, body: Union[dict, str]): | ||
json_content = { | ||
"statusCode": code, | ||
} | ||
return json_content |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.