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
| --- | |
| modules: | |
| - acm | |
| - s3 | |
| - cloudfront | |
| - wafv2-fortinet |
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
| NODES_CONFIG = [ | |
| "tf-ci-worker-1": [ | |
| AWS_ACCOUNT: "111111111111", | |
| ENV_NAME: "prod1", | |
| DEPLOY_ROLE_ARN: "arn:aws:iam::111111111111:role\\/terraform", | |
| PROD_VPC_CIDR: "10.210.0.0\\/16" | |
| ], | |
| "tf-ci-worker-2": [ | |
| AWS_ACCOUNT: "222222222222", | |
| ENV_NAME: "prod2", |
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
| options { // Default build options | |
| lock label: "tf-ci", variable: "LOCKED_NODE", quantity: 1 | |
| buildDiscarder(logRotator(numToKeepStr: '10')) | |
| timeout(time: 240, unit:'MINUTES') | |
| timestamps() | |
| } |
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
| def payload_json = "${env.json_payload}".substring(1, "${env.json_payload}".length() - 1); // removing extra curly braces from json payload | |
| def parsed_json = new JsonSlurper().parseText("{$payload_json}"); | |
| env.REPO_FULL_NAME = parsed_json.pullrequest.source.repository.full_name // Get full repo name (consists of: <workspace>/<repo_slug>) | |
| env.COMMIT_HASH = parsed_json.pullrequest.source.commit.hash // Get pull request commit hash | |
| env.PULL_REQUEST_ID = parsed_json.pullrequest.id // Get pull request id | |
| env.PULL_REQUEST_TITLE = parsed_json.pullrequest.title // Get pull request title | |
| env.PULL_REQUEST_URL = parsed_json.pullrequest.links.html.href // Get pull request URL | |
| env.PULL_REQUEST_COMMENT_COUNT = parsed_json.pullrequest.comment_count // Get number of comments in pull request | |
| env.BRANCH = parsed_json.pullrequest.source.branch.name // Get pull request branch name | |
| env.AUTHOR = parsed_json.pullrequest.author.nickname // Get username of author |
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
| stage("Send notification") { | |
| steps { | |
| script { | |
| withCredentials([string(credentialsId: 'slack-app', variable: 'slack_token')]) { | |
| env.SLACK_USER_ID = sh (script: """ | |
| SLACK_USER_ID="\$(curl -d \"token=${slack_token}\" -d \"email=${env.AUTHOR_EMAIL}\" https://slack.com/api/users.lookupByEmail | jq -r '.user.id')" | |
| echo \$SLACK_USER_ID""", returnStdout: true).trim() | |
| } | |
| if ("${env.PULL_REQUEST_COMMENT_COUNT}" == "0") { | |
| sendBitbucketComment ("${env.REPO_FULL_NAME}", "${env.PULL_REQUEST_ID}", "${env.WELCOME_COMMENT}") |
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
| import sys | |
| import boto3 | |
| def cleanup(): | |
| get_last_modified = lambda obj: int(obj['LastModified'].strftime('%s')) | |
| s3 = boto3.client('s3') | |
| result = s3.list_objects(Bucket=bucket, Delimiter='/') | |
| for dir in result.get('CommonPrefixes'): | |
| print('Directory: ' + str(dir['Prefix'])) |
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
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: 'Template for Lambda Fuction for stopping AWS resources (EC2, RDS, ASG)' | |
| ### OUTPUT ### | |
| Outputs: | |
| LambdaRoleARN: | |
| Description: Role for Lambda execution. | |
| Value: | |
| Fn::GetAtt: | |
| - LambdaRole |
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
| import boto3 | |
| custom_ec2_filter = [ | |
| { | |
| 'Name': 'instance-state-name', | |
| 'Values': ['running', 'pending'] | |
| } | |
| ] | |
| # Combination of tag key and value to prevent shutdown/downscale resources |
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
| { | |
| "Version": "2012-10-17", | |
| "Id": "certbot-dns-route53", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "route53:ListHostedZones", | |
| "route53:GetChange" | |
| ], |