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: - '