-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ami start and record lambda (#112)
- Loading branch information
1 parent
76ef4b3
commit e045004
Showing
6 changed files
with
331 additions
and
7 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,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 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,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.