Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tubone24/lambda_container_support_with_selenium
This is Creating a template that runs Selenium from Alpine container and deploying Lambda - Container Image Support and applying it with Terraform
https://github.com/tubone24/lambda_container_support_with_selenium
containers lambda selenium-python terraform
Last synced: 1 day ago
JSON representation
This is Creating a template that runs Selenium from Alpine container and deploying Lambda - Container Image Support and applying it with Terraform
- Host: GitHub
- URL: https://github.com/tubone24/lambda_container_support_with_selenium
- Owner: tubone24
- License: mit
- Created: 2020-12-24T15:04:36.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T14:56:27.000Z (about 1 year ago)
- Last Synced: 2024-04-13T04:55:37.743Z (9 months ago)
- Topics: containers, lambda, selenium-python, terraform
- Language: Python
- Homepage:
- Size: 9.89 MB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lambda_container_support_with_selenium
[![license](https://img.shields.io/github/license/tubone24/lambda_container_support_with_selenium.svg)](LICENSE)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)> Lambda Container Support, use selenium, use terraform
This is Creating a template that runs Selenium from Alpine container and deploying **Lambda - Container Image Support** and applying it with Terraform
## Table of Contents
- [Background](#background)
- [Install](#install)
- [Usage](#usage)
- [License](#license)## Background
In our company, we have a lot of Slack workSpaces.
In addition, we also post an attendance to Slack, but it's a bit of a hassle to post everything to all the different workSpaces.
Then, it seems that we can solve this problem by using Slack API and mutual posting, but I heard that some WorkSpace prohibits external linkage for security reasons. What the heck...
So, if we take a screenshot of the secure Slack and post it to the Slack we usually use, at least we've communicated, so it'll be easy! So let's make it.
![img](https://i.imgur.com/odKSxHU.png)
More information? Go to my Article: [Lambda – Container Image Supportを使ってAlpineからSeleniumが動くコンテナを作ってTerraformで当てる
](https://blog.tubone-project24.xyz/2020/12/25/selenium-lambda-container)### Architects
Use Lambda in VPC to create a Lambda with a fixed global IP address, and push the Docker Image to the ECR.
Also, for security reasons, the login password to Slack will be encrypted using AWS KMS.
![img](https://i.imgur.com/GPamgYL.png)
## Install
### System Requirements
- Terraform v0.12 or more
- Make
- Docker
- Python 3.7### Preconditions
This tool used by Terraform, Make, Python and Docker.
So, Install those apps before run this tool.
#### Quick Install
With my [mac-auto-setup](https://github.com/tubone24/mac-auto-setup), you can build the environment you need for your Mac.
#### Set up your environment
When executing the container, you need to specify the following environment variable.
Write your environments to your tfvars.
| | | |
| ------------------------ | -------------------------------------------------------------------- | --------------------------------------------------- |
| Name | Meaning | Ex |
| SLACK_TOKEN | Need to uploading the screenshot using Slack API | xnob-xxxxxx |
| SLACK_CHANNEL_ID | Channel id where you want to upload the screenshot(not channel name) | C01SJAKESAD |
| SLACK_USERNAME | Slack account login email | [email protected] |
| SLACK_PASSWORD | Slack account login password | KMS encoded password |
| SLACK_LOGIN_URL | Slack login URL | https://hoge-hoge.slack.com |
| SLACK_ATTEND_CHANNEL_URL | Screenshot point url | https://app.slack.com/client/XXXXXXXXXX/XXXXXXXXXXX |In addition, set the security group id and subnet id to configure Lambda in VPC.
```
$ cp terraform/tfvars.tfvars.tpl env.tfvars
$ vi terraform/env.tfvars$ cp terraform/ecr/tfvars.tfvars.tpl env.tfvars
$ vi terraform/ecr/env.tfvars
```SLACK_PASSWORD must be encrypted using AWS KMS, so you need to use kms_encrypt.py scripts.
```
pip install -r requirements.txt
python scripts/kms_encrypt.py keyId password
```### Build Container Image
The following commands should be executed in the project root.
```
make build-push-image ENV=env
```Or built image from GitHub packages
```
docker pull docker.pkg.github.com/tubone24/lambda_container_support_with_selenium/selenium:latest
docker tag docker.pkg.github.com/tubone24/lambda_container_support_with_selenium/selenium:latest your-ecr-repo-uri
docker push your-ecr-repo-uri
```### Deploy
The following commands should be executed in the project root.
First, Create ECR Repository
```
make backend ENV=envmake remote-enable-ecr ENV=env
make create-env-ecr ENV=env
make plan-ecr ENV=env
make apply-ecr ENV=env
```Second, Deploy Lambda
```
make remote-enable ENV=envmake create-env ENV=env
make plan ENV=env
make apply ENV=env
```## Usage
Post a screenshot of the Slack attend channel to Slack at a set time each day.
![img](https://i.imgur.com/oHtRLCO.png)
## License
[MIT © tubone24](LICENSE)