Entradas

Athena with AWS

Create implementation athena AWS CODE: export class AthenaAWSImpl { private readonly logger: any; private readonly athena: AWS.Athena; constructor(logger: any, session: { accessKeyId: string; secretAccessKey: string; sessionToken: string; } | undefined) { this.logger = logger; this.athena = new AWS.Athena({ apiVersion: '2017-05-18', region: Constants.AWS_REGION, credentials: session, }); } /** * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Athena.html */ async getTableMetadata(input: { catalogName: string, databaseName: string, tableName: string }): Promise { try { const params = { CatalogName: input.catalogName,...

Create a SQS and subscribe to SNS | create a SNS in AWS and subscribe a queue (SQS)

Stack to Create a SQS and subscribe to SNS | create a SNS in AWS and subscribe a queue (SQS) Cloudformation: Template for create a SNS in AWS and subscribe a queue (SQS) Description: Create an SNS Parameters: Stage: Description: Environment Name Type: String CrossAccountExternalAccountId: Type: String Description: Account Id StandardTopicName: Type: String Description: Queue Name Resources: SnsTopicRef: Type: AWS::SNS::Topic Properties: TopicName: !Join [ "-", [!Ref StandardTopicName] ] DisplayName: !Join [ "-", [!Ref StandardTopicName] ] Tags: - Key: "environment" Value: !Ref Stage SnsTopicRefPolicy: Type: AWS::SNS::TopicPolicy Properties: PolicyDocument: Version: ...

Stack to create a SNS in AWS

Stack to create a SNS in AWS Cloudformation: Description: Create an SNS Parameters: Stage: Description: Environment Name Type: String CrossAccountExternalAccountId: Type: String Description: Account Id StandardTopicName: Type: String Description: Queue Name Resources: SnsTopicRef: Type: AWS::SNS::Topic Properties: TopicName: !Join [ "-", [!Ref StandardTopicName] ] DisplayName: !Join [ "-", [!Ref StandardTopicName] ] Tags: - Key: "environment" Value: !Ref Stage SnsTopicRefPolicy: Type: AWS::SNS::TopicPolicy Properties: PolicyDocument: Version: "2012-10-17" Statement: - Sid: "allow-cross-account-lambda" ...

Stack to create a SQS in AWS

Stack to create a SQS in AWS Cloudformation: AWSTemplateFormatVersion: '2010-09-09' Description: Template to create the sqs in aws Parameters: Stage: Description: Environment Name Type: String StandardQueueName: Type: String Description: Queue Name Resources: QueueRefDLQ: Type: AWS::SQS::Queue Properties: QueueName: !Join [ "-", [!Ref StandardQueueName, "dlq"] ] Tags: - Key: "environment" Value: !Ref Stage QueueRef: Type: AWS::SQS::Queue Properties: QueueName: !Ref StandardQueueName ReceiveMessageWaitTimeSeconds: 10 VisibilityTimeout: 900 KmsMasterKeyId: alias/aws/sqs RedrivePolicy: deadLetterTargetArn: !GetAtt - QueueRefDLQ ...

Stack to create a table with DynamoDB in AWS

Stack to create a table with DynamoDB in AWS Cloudformation: Description: Table for create an user Parameters: Stage: Description: Environment Name Type: String DynamodbTableName: Description: Table name Type: String Resources: SATContractsDBTable: Type: AWS::DynamoDB::Table Properties: TableName: !Sub "${DynamodbTableName}" BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: id AttributeType: N - AttributeName: username AttributeType: S KeySchema: - AttributeName: id KeyType: HASH - AttributeName: username KeyType: RANGE Tags: - ...

Stack to create a S3 bucket

Stack to create a S3 bucket Cloudformation: Description: Stack to create a S3 bucket for only read files. Parameters: Stage: Description: Environment Name Type: String BucketName: Type: String Description: The bucket name OriginURL: Description: Origin url name Type: String Resources: S3FilesBucket: Type: AWS::S3::Bucket Properties: BucketName: !Ref BucketName VersioningConfiguration: Status: Enabled BucketEncryption: ServerSideEncryptionConfiguration: - ServerSideEncryptionByDefault: SSEAlgorithm: AES256 PublicAccessBlockConfiguration: BlockPublicAcls : true BlockPublicPolicy : true IgnorePublicAcls : true RestrictPublicBuckets : true CorsConfiguration: CorsRules: - AllowedHeaders: - x-amz-* AllowedMethods: - PUT AllowedOrigins: - !Ref OriginURL ExposedHeaders: - Connection - Server - ...

Creation of SQS FIFO in AWS

Creation of SQS FIFO in AWS Cloudformation: AWSTemplateFormatVersion: '2010-09-09' Description: Template to create the sqs of websocket connections Parameters: StandardQueueName: Type: String Description: Queue Name Resources: QueueRefDLQ: Type: AWS::SQS::Queue Properties: FifoQueue: true #QueueName: !Join [ "-", [!Ref StandardQueueName, "dlq"] ] QueueName: Fn::Join: - '' - - Ref: StandardQueueName - dlq - ".fifo" QueueRef: Type: AWS::SQS::Queue Properties: ContentBasedDeduplication: true FifoQueue: true QueueName: Fn::Join: - '...

Websocket with API Gateway AWS | Websocket con API Gateway AWS

Ejemplo de implementación de Websocket con API Gateway de AWS. Cloudformation: AWSTemplateFormatVersion: '2010-09-09' #Transform: AWS::Serverless-2016-10-31 Description: websockets to notify to the frontend. Parameters: WebSocketName: Description: Websocket name Type: String Resources: WebSocket: Type: AWS::ApiGatewayV2::Api Properties: Name: !Sub ${WebSocketName} ProtocolType: WEBSOCKET RouteSelectionExpression: "$request.body.action" Description: "Mock WebSocket API Gateway." ConnectRoute: Type: AWS::ApiGatewayV2::Route Properties: ApiId: !Ref WebSocket RouteKey: $connect #RouteResponseSelectionExpression: '$default' AuthorizationType: NONE OperationN...

Ejemplo Log4j 2 en JAVA | Log4j 2 en Springboot | Configuración Log4j 2 | Log4j 2 in SpringBoot| Example Log4j 2 in SpringBoot | Configuring Log4j 2

Imagen
Log4j versión 2.x en JAVA |  Log4j versión 2.x en  SpringBoot Apache Log4j 2 o 2.x es una actualización muy importante de Log4j, la cual proporciona innumerables mejoras con respecto a las versiones anteriores, entre estas mejoras: Logback, manejo asíncrono, etc. Objetivo Configurar Log4j versión 2 o 2.x en proyectos Spring. Requisitos: Java 11 (Open) Eclipse SpringBoot 2.2.4.RELEASE Maven En Acción: Para este ejemplo se debe contar con un proyecto en SpringBoot, el cual se pueda implementar o mejorar el uso de Log4j 2 o 2.x. log4j2-spring.xml El archivo de configuración para Log4j versión 2 se define de dos formas: logj2.xml para proyectos sin Spring log4j-spring.xml para proyectos que usen Spring Para ambos archivos se mantiene la misma declaración de propiedades. <? xml version = "1.0" encoding = "UTF-8" ?> <!--https://logging.apache.org/log4j/2.x/manual/configuration.html--> < Configuration status = "TRACE" monitorInterval = "...