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 com.amazonaws.auth.AWSCredentialsProvider; | |
import org.springframework.beans.BeansException; | |
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | |
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; | |
import java.util.Map; | |
import java.util.Properties; | |
/** | |
* Class for reading properties from AWS Parameter Store and allowing spring to inject them in the |
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 com.amazonaws.ClientConfiguration; | |
import com.amazonaws.auth.AWSCredentialsProvider; | |
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement; | |
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClient; | |
import com.amazonaws.services.simplesystemsmanagement.model.*; | |
import org.apache.commons.lang3.tuple.ImmutablePair; | |
import org.apache.commons.lang3.tuple.Pair; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; |
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
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Description: "Monitoring - Dashboard - Http Errors" | |
Parameters: | |
EnvironmentName: | |
Type: String |
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 com.amazonaws.ClientConfiguration; | |
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.env.EnvironmentPostProcessor; | |
import org.springframework.core.env.ConfigurableEnvironment; | |
import org.springframework.core.env.MapPropertySource; | |
import java.util.HashMap; | |
import java.util.Map; |
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
--configurations '[{"Classification":"hive-site","Properties":{"hive.metastore.client.factory.class":"com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"}},{"Classification":"spark-hive-site","Properties":{"hive.metastore.client.factory.class":"com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"}}]' |
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 pyspark.sql import SparkSession | |
spark = SparkSession.builder.appName("SimpleApp").enableHiveSupport().getOrCreate() | |
spark.sql("use dev") | |
spark.sql("show tables").show() | |
spark.sql("SELECT * FROM myTable").show(10) |
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 flask import jsonify | |
from flask_restx import Resource, Namespace | |
health_api = Namespace('health', 'health check api') | |
@health_api.route('health_check', doc=False) | |
class HealthCheck(Resource): | |
def get(self): | |
response = {"Status": "OK"} | |
return jsonify(response) |
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 injector import inject | |
from flask import request, g | |
@inject | |
def api_before_request(db_connection: MyDbConnectionClass): | |
if not request.path.startswith("/health_check"): | |
logger.info(f"Request received to: {request.url}, headers: {request.headers}, body: {request.json}”) | |
g.user_info = db_connection.query_user_info(request.headers.get('Username’)) |
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 flask_restx import Api | |
from .health_check.health import health_api as health_namespace | |
api = Api( | |
title='Title', | |
version='1.0', | |
description='description', | |
doc='/api-docs', | |
) |
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 logging | |
import os | |
from flask import Flask, | |
from flask_injector import FlaskInjector | |
from injector import singleton, Injector, Module | |
from common_dal import DataAccessLayer, initialize_db_connection | |
from apis.api_queries import api_before_request | |
OlderNewer