Skip to content

Instantly share code, notes, and snippets.

View nhammad's full-sized avatar

nhammad

View GitHub Profile
resource "aws_ecs_cluster" "gtm" {
name = "gtm"
setting {
name = "containerInsights"
value = "enabled"
}
}
resource "aws_ecs_task_definition" "PrimaryServerSideContainer" {
family = "PrimaryServerSideContainer"
resource "aws_iam_role" "gtm_container_exec_role" {
name = "gtm_container_exec_role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Effect = "Allow",
Principal = {
resource "aws_route53_zone" "analytics" {
name = "analytics.cloud"
}
resource "aws_acm_certificate" "cert" {
domain_name = "*.analytics.cloud"
validation_method = "DNS"
}
resource "aws_route53_record" "analytics" {
{
"channel": "ABCDEBF1",
"attachments":
[
{
"mrkdwn_in": ["text"],
"color": "#36a64f",
"pretext": "Optional pre-text that appears above the attachment block",
"author_name": "author_name",
"author_link": "http://flickr.com/bobby/",
import json
import urllib.parse
import requests
import pyarrow.parquet as pq
from io import BytesIO
import re
from datetime import datetime
s3 = boto3.client("s3")
# Copyright 2013-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
# use this file except in compliance with the License. A copy of the License
# is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "LICENSE.txt" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
from airflow.contrib.sensors.python_sensor import PythonSensor
....
with DAG('test_airflow_dag', description='testing_python_sensor',
schedule_interval='30 5 * * *',
start_date=datetime(year=2020, month=01, day=12),
catchup=False,
default_args=args) as dag:
.....
resource "aws_cloudwatch_metric_alarm" "alarm" {
alarm_name = local.alarm_name
metric_name = var.metric_name
namespace = var.namespace
period = var.period
evaluation_periods = var.evaluation_periods
comparison_operator = var.comparison_operator
statistic = var.statistic
threshold = var.threshold
actions_enabled = true
resource "aws_sns_topic" "turn-off-topic" {
name = local.topic_name
}
resource "aws_sns_topic_subscription" "turn-off-subscrtion" {
topic_arn = aws_sns_topic.turn-off-topic.arn
protocol = "lambda"
endpoint = aws_lambda_function.processing_lambda.arn
}
data "archive_file" "lambda_zip" {
type = "zip"
source_file = "${path.module}/src/turn_off_lambda.py"
output_file_mode = "0666"
output_path = "${path.module}/bin/turn_off_lambda.zip"
}
resource "aws_lambda_function" "processing_lambda" {
filename = data.archive_file.lambda_zip.output_path
function_name = local.processing_lambda_name