- Using selenium, push ocn top page "OCN訪問ポイント" button automatically to get Dpoint.
- OCN site has two factor authentication, but AWS Lambda cannot get SMS Auhentication PIN when running.
- That's why, this Lambda use prepared
cookies.pkl
to login. - cookies.pkl must have been created by create_cookies.py locally and uploaded to S3 beforehand.
- python 3.7 (chromium-headless supported version)
- headless-chromium-amazonlinux-2017-03
- chromedriver_linux64 see requirements.txt
- Create AWS IAM Users for AWS CLI and attached
AdministratorAcess
. - install aws cli
- create ~/.aws/config and paste AccessKey, SecretAccessKey.
# ~/.aws/config
[profile default]
region = ap-northeast-1
aws_access_key_id = <<IAM AccessKey>>
aws_secret_access_key = <<IAM SecretAccessKey>>
- check connection
aws s3 ls --profile gr360
# install python3.7
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7
# install python3.7 venv
sudo apt install python3.7-venv
# create python3.7 venv
python3.7 -m venv ~/ocn_daily_login
source ~/ocn_daily_login/bin/activate # activate venv
# download repository
git clone https://github.com:RyosukeDTomita/ocn_dialy_login_aws_lambda.git
# set up
cd ocn_dialy_login_aws_lambda
pip -r requirements.txt
cd ./create_selenium_driver_layers
source mk_driver_lib_layer.sh
ls create_selenium_driver_layers/headless
chromedriver* headless-chromium* locales/
- download zip
- unzip
- install
- check
# install command
sudo ./sam-installation/install
sam --version
sam build
sam deploy --guided --capabilities CAPABILITY_NAMED_IAM
sam delete # delete stack
If you want to use GUI, see README_gui.md
For developer, you can only deploy IAM Role and S3 for the first deploy.
# only initial deploy
sam build -t ./template_s3iam.yaml
sam deploy --guided --capabilities CAPABILITY_NAMED_IAM
# skip deploy S3 and IAM Role
sam build -t template_dev.yaml
sam deploy --guided
Note Do not use
-t
insam deploy
If you use, python library(boto3 and seleniumA) do not deploy with lambda andNo module name
Error occured.
- create cookies.pkl and upload to S3.
python3 create_cookies.py --userid <docomo userid> --password <password> --bucket <bucket-name> --profile <aws cli profile>
- Then, every 01:00 AM, EventBridge call lambda function and push OCN daily login button.
cookies.pkl
, you can use aws cli.
aws s3 cp cookies.pkl s3://cookie-for-iceman2 --acl private --profile=default