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
from jenkinsapi.jenkins import Jenkins | |
from jenkinsapi.utils.requester import Requester | |
from subprocess import check_output | |
import requests | |
requests.packages.urllib3.disable_warnings() | |
# Using AWS AMI allows using the private IP and AWS instance name for the node's registration | |
# Change these value if you're using other AMI or not using AWS at all | |
instance_name = check_output(["ec2-metadata", "-i"]).split()[1] | |
instance_ip = check_output(["ec2-metadata", "-o"]).split()[1] |
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
FROM python | |
RUN apt-get update && apt-get install -y \ | |
vim \ | |
curl | |
LABEL image.version="0.0.1-beta" |
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
payload = {"channel": "#general", "username": "webhookbot", "text": "Testing slack webhook", "icon_emoji": ":ghost:"} | |
url = 'https://hooks.slack.com/services/0000000000/0000000000/0000000000' | |
requests.post(url, data=json.dumps(payload)) |
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
def lambda_handler(event, context): | |
import boto3 | |
client = boto3.client('ecs', aws_access_key_id='', aws_secret_access_key='') | |
response = client.list_tasks(cluster='mycluster', family='myservice', maxResults=1,desiredStatus='RUNNING') | |
stoptask = response['taskArns'][0].split('/')[1] | |
print client.stop_task(cluster='mycluster', task=stoptask, reason='chaos monkey') |
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
import os | |
import boto3 | |
import datetime | |
import dateutil | |
DEFAULT_MAX_MEM = 3000 | |
LOW_CLUSTER_CPU_TH = 20 | |
HIGH_CLUSTER_CPU_TH = 65 | |
CONTAINERS_MAX_MEM = { | |
'cluster1': 1200, |
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
TaskDefinition: | |
Type: AWS::ECS::TaskDefinition | |
Properties: | |
Family: !Ref ServiceName | |
ContainerDefinitions: | |
- Name: !Sub ${ServiceName}-container | |
Essential: true | |
Image: !Ref DockerImage | |
Memory: !Ref Memory | |
PortMappings: |
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
Resources: | |
ECSCluster: | |
Type: AWS::ECS::Cluster | |
Properties: | |
ClusterName: !Ref EnvironmentName | |
ECSAutoScalingGroup: | |
Type: AWS::AutoScaling::AutoScalingGroup | |
Properties: | |
VPCZoneIdentifier: !Ref Subnets |
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
Resources: | |
Service: | |
Type: AWS::ECS::Service | |
DependsOn: ListenerRule | |
Properties: | |
Cluster: !Ref Cluster | |
ServiceName: !Ref ServiceName | |
LaunchType: !Ref LaunchType | |
DesiredCount: !Ref DesiredCount | |
DeploymentConfiguration: |
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
TaskDefinition: | |
Type: AWS::ECS::TaskDefinition | |
Properties: | |
Cpu: !Ref VCpu | |
RequiresCompatibilities: | |
- !Ref RequiresCompatibilities | |
Family: !Ref ServiceName | |
NetworkMode: !Ref NetworkMode | |
ExecutionRoleArn: arn:aws:iam::000:role/EcsTaskExecutionRole | |
TaskRoleArn: arn:aws:iam::000:role/EcsTaskExecutionRole |
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
TargetGroup: | |
Type: AWS::ElasticLoadBalancingV2::TargetGroup | |
Properties: | |
VpcId: !Ref VPC | |
Port: 80 | |
Protocol: HTTP | |
Matcher: | |
HttpCode: 200-299 | |
HealthCheckIntervalSeconds: 80 | |
HealthCheckPath: !Ref HealthCheckPath |
OlderNewer