Created
July 12, 2018 16:48
-
-
Save jtroberts83/36c8813faf0d95962206cb6319d9b02d to your computer and use it in GitHub Desktop.
Salactus User Data For Amazon Linux AMI
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
#!/bin/bash | |
SALACTUS_REDIS='your-redis-server-arn-redis.yfyfyfyfy.0001.use1.cache.amazonaws.com' | |
export AWS_DEFAULT_REGION='us-east-1' | |
echo "export AWS_DEFAULT_REGION='us-east-1'" >> /root/.bash_profile | |
echo "export SALACTUS_REDIS="$SALACTUS_REDIS"" >> /root/.bash_profile | |
echo "source /root/cloud-custodian/bin/activate" >> /root/.bash_profile | |
creds_file="/root/.aws/credentials" | |
instance_profile=`curl --noproxy 169.254.169.254 http://169.254.169.254/latest/meta-data/iam/security-credentials/` | |
aws_access_key_id=`curl -s --noproxy 169.254.169.254 http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'` | |
aws_secret_access_key=`curl -s --noproxy 169.254.169.254 http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'` | |
aws_session_token=`curl -s --noproxy 169.254.169.254 http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep Token | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'` | |
aws configure set aws_access_key_id $aws_access_key_id | |
aws configure set aws_secret_access_key $aws_secret_access_key | |
aws configure set aws_session_token $aws_session_token | |
cd /root | |
git clone https://github.com/capitalone/cloud-custodian | |
cd cloud-custodian | |
make install | |
source bin/activate | |
cd tools/c7n_org | |
python setup.py develop | |
DATE=`date +%Y-%m-%d` | |
cd /root/cloud-custodian/tools/c7n_salactus/ | |
## Replaces some varialbes in the script to work with Amazon Linux AMI and decrease the process numbers for stability | |
sed -i -e 's/user=ubuntu/user=root/g' supervisord.conf | |
sed -i -e 's/\/home\/ubuntu\/index\/bin\/rqworker/\/root\/cloud-custodian\/bin\/rqworker/g' supervisord.conf | |
sed -i -e 's/numprocs=96/numprocs=56/g' supervisord.conf | |
sed -i -e 's/numprocs=16/numprocs=10/g' supervisord.conf | |
sed -i -e 's/numprocs=8/numprocs=6/g' supervisord.conf | |
yum install -y python27-devel.x86_64 | |
yum install gcc -y | |
pip install supervisor | |
pip install msgpack | |
pip install lz4 | |
python setup.py develop | |
export SALACTUS_REDIS="$SALACTUS_REDIS" | |
aws s3 cp s3://yours3bucket/c7n-salactus-config.yaml c7n-salactus-config.yaml | |
c7n-salactus run --config c7n-salactus-config.yaml --not-bucket our-global-cloudtrail-logs --not-bucket our-s3-logs --not-bucket our-devteam4-s3-logs --not-bucket our-cloud-custodian | |
supervisord -c supervisord.conf -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment