teleren/devto huggingface dataset:
Create CloudWatch Alarms with Python AWS CDK 
Tags: aws, cdk, iac, cloudnative
Published: 2021-10-21 23:24:14

## Create the alarm
Put this into your Python AWS CDK stack to create an alarm on a bucket asigned to a varibale named `bucket`

```
bucket = s3.Bucket...

s3_size_alarm = cloudwatch.Alarm(self, 'bucket_overloaded_alarm',
    metric= cloudwatch.Metric(
        namespace = "AWS/S3", 
        metric_name = "BucketSizeBytes",
        dimensions={
            "BucketName": bucket.bucket_name,
            "StorageType": "StandardStorage",
        },
        period = core.Duration.days(1),
        statistic="Maximum",
    ), 
    evaluation_periods=1, 
    threshold=1000000000 #1 GB
)
```

This will create a CloudWatch alarm which:

* Alarm if the size of the bucket goes over 1GB
* Only monitors objects with the `StandardStorage` type

Relevant CDK docs:
* https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cloudwatch/Alarm.html
* https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cloudwatch/Metric.html


**Warning:** Don't rely on an alarm watching the `BucketSizeBytes` metric to make sure your bucket doesn't grow too large. This metric is [only collected once a day](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudwatch-monitoring.html). Consider opting in to [S3 request metrics](https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html) for more in-depth S3 monitoring

## Create alarm action
Alarms aren't very useful if they don't do anything. Setup some actions:

```
topic = sns.Topic.from_topic_arn(self,'snstopic',"arn:aws:sns:us-east-1:123456789012:alarm-go-ahhhhhhhhhhhh")

s3_size_alarm.add_alarm_action(
    cloudwatch_actions.SnsAction(
        topic = topic
    )
)
```

Relevant CDK docs:
* https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_sns/Topic.html#aws_cdk.aws_sns.Topic.from_topic_arn


## More CDK or AWS Serverless Questions?
Feel free to leave a comment here or hit us up on [LinkedIn](https://www.linkedin.com/company/signet-seal).

Want to learn more about how SignetSeal can help make your chats more secure? Read more about us on our [website](https://signetseal.com/)
Customize any website with your own CSS
Tags: javascript, webdev, css
Published: 2021-10-21 23:18:22

How to hide those distracting PrimeGaming notifications!

If you have digital OCD like me then these little red alerts drive you crazy 🤪

----------
<b>Yo!</b> I post byte-sized tips like these often. Follow me if you crave more! 🍿

I'm on [TikTok](https://www.tiktok.com/@js_bits), [Twitter](https://twitter.com/JS_Bits_Bill) and I have a new [debugging course](https://jsbits-yo.com/bug-bash/) dropping soon!
I need your help
Tags: help, webdev, programming
Published: 2021-10-21 22:22:57

I'm starting a project on Medium.com
¿Can you help me following muy account? I'll really appreciate It ❤️.

I'll create post about programming, front end, back end and many more. Hope yo like It 🚀.

My link: yjdev.medium.com
Please follow me 🙏
Build a REST API with Node.js, Express, TypeScript, MongoDB & Zod - Full course
Tags: node, typescript, tutorial, javascript
Published: 2021-10-21 22:22:49

In this series of videos you will build a REST API with Node.js, Express, TypeScript, MongoDB and Zod. You will learn how to build out the REST API, how to test it and how to build a simple user interface with React that includes authentication.

By following all the videos, you will learn:
* REST API concepts
* Testing REST APIs
* TypeScript
* JWT access & refresh tokens
* React with Nextjs

In the first video we build out the REST API with a simple authentication system.

{% youtube BWUi6BS9T5Y %}


In this next video we fix an issue with Mongoose having no export for DocumentDefinition and you will learn a better way to type the service inputs.

{% youtube 5-1KuU-21uI %}

In this video you will learn how to test the REST API and some testing best-practices.

{% youtube r5L1XRZaCR0  %}

In this video you will build out a user interface for your REST API with React & Next.js. You will learn how the access & refresh tokens are implemented on the client-side.

{% youtube oSz23pPBpFY  %}

Still to come:
* Google OAuth
* Deployment with Docker & Caddy
* Metrics with Prometheus
Day 477 : Reloaded
Tags: hiphop, code, coding, lifelongdev
Published: 2021-10-21 21:40:07

_liner notes_:
- Professional : Had a couple of meetings. Reviewed a PR. Created my own pull request to update some stuff in the docs. Then worked on a demo application.

- Personal : Last night, I went through a bunch of tracks for the radio show. Explored a couple of possible solutions for the issue I'm running into with my side project and went down yet another rabbit  hole. To try one out, I would have to make my side project installable, but when I tried a demo that was presented as an example, it didn't work. Not sure if it's the demo or the actual API. Probably look more into it. I did look more into the one API that would totally do what I need, but it doesn't look like there is much development happening currently.

![A desert with orange sand dunes in Souss-Massa-Drâa, Morocco at night under a sky full of stars.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qpcooyksds2ktcdcjo7j.jpg)

Pretty much going to do a repeat of last night. The last episode of "Squid Game" that I watched. Wow! I think my plan needs to be reloaded on how I approach getting this issue resolved. Going to give it the weekend and see.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube o17RnKl36GE %}
Cloning, how does it work?
Tags: rust, help
Published: 2021-10-21 21:23:01

Hey! 
Recently, I have been faced with an error. I have a DasHap of a &str and a bool, and I have 2 functions, each in a loop, each in their own thread. I need to share this dashmap between both threads, so I wrapped it in `Arc`. I get a borrowing error, of course, and was suggested to clone outside of the thread because the closure is `async move`. But, then, if I update the not-cloned value, that won't reflect on the cloned-value, and to update the cloned-value, I have to reference it where the not-cloned value changes, which is in a thread, that would cause borrowing errors.
To sum up, having a value being cloned outside of a loop, requiring the original value to be updated, subsequently also requires the cloned-value to be update, but can't be done as if I update the cloned-value in thread 1, I can't use it in thread 2 because of borrowing errors.

Any help appreciated!
Fargate + EFS Permissions using CDK
Tags: aws, cdk, devops
Published: 2021-10-21 21:16:20

---
title: Fargate + EFS Permissions using CDK
published: true
description: AWS EFS has 2 permission layers, IAM and POSIX. It took too long to figure that out.
tags: 
- AWS
- CDK
- DevOps
cover_image: https://bliskavka.com/2021/10/21/AWS-CDK-Fargate-with-EFS/cat.jpg
canonical_url: https://bliskavka.com/2021/10/21/AWS-CDK-Fargate-with-EFS/
---


I struggled WAY too long trying to sort out the permissions for EFS. Turns out, there are 2 layers. The IAM role, and the Posix permissions. Both throw a similar looking access denied. Finally!

Don't judge me on the single AZ. I am running a single task in Fargate and only need one instance.

```typescript
const {vpc, az, region, account} = props;

const fileSystem = new FileSystem(this, 'Efs', {
  vpc,
  performanceMode: PerformanceMode.GENERAL_PURPOSE,
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
    onePerAz: true,
    availabilityZones: [az]
  }
});

const accessPoint = new AccessPoint(this, 'AccessPoint', {
  fileSystem: fileSystem,
});

const task = new ecs.FargateTaskDefinition(this, 'Task', {
  cpu: 256,
  memoryLimitMiB: 512
});

const volumeName = 'efs-volume';

task.addVolume({
  name: volumeName,
  efsVolumeConfiguration: {
    fileSystemId: fileSystem.fileSystemId,
    transitEncryption: 'ENABLED',
    authorizationConfig:{
      accessPointId: accessPoint.accessPointId,
      iam: 'ENABLED'
    }
  }
});

const container = task.addContainer('Container', {
  image: ecs.ContainerImage.fromAsset('./container'),
  portMappings: [{hostPort: 80, containerPort: 80}],
});

container.addMountPoints({
  containerPath: '/mount/data',
  sourceVolume: volumeName,
  readOnly: false
});

task.addToTaskRolePolicy(
  new iam.PolicyStatement({
    actions: [
      'elasticfilesystem:ClientRootAccess',
      'elasticfilesystem:ClientWrite',
      'elasticfilesystem:ClientMount',
      'elasticfilesystem:DescribeMountTargets'
    ],
    resources: [`arn:aws:elasticfilesystem:${region}:${account}:file-system/${fileSystem.fileSystemId}`]
  })
);

task.addToTaskRolePolicy(
  new iam.PolicyStatement({
    actions: ['ec2:DescribeAvailabilityZones'],
    resources: ['*']
  })
);
```

I hope this save someone a headache!

[Originally posted on my blog](https://bliskavka.com/2021/10/21/AWS-CDK-Fargate-with-EFS)
What would you like to know about A/B Testing? Answer to be featured on our podcast 🎧
Tags: podcast, discuss
Published: 2021-10-21 21:13:06

---
title: What would you like to know about A/B Testing? Answer to be featured on our podcast 🎧  
published: true
description: 
tags: podcast, discuss
---

The [DevDiscuss Podcast](dev.to/devdiscuss) begins with an interview and ends with commentary from listeners — and we like to feature the _actual_ voices from our community!

To inform an upcoming episode of the show, we'd like to know...

> ### **What would you like to know about A/B Testing?**

For your chance to hear your actual comments on an upcoming episode, answer the question above by:

- Calling our Google Voice at +1 (929)500-1513 and leave a message 📞

- Sending a voice memo to pod@dev.to 🎙

- OR, leaving a comment here (we'll read your response aloud for you) 🗣

Please send in your recordings by Wednesday, October 27th at 9 AM, ET (1 PM UTC, 6 AM PT)

#### Voice recordings will be given priority placement 😉

Catch up on recent episodes of the show [here](https://dev.to/devdiscuss) 👀
Solid design principles part 1
Tags: architecture, design, beginners, programming
Published: 2021-10-21 20:30:06

In this short series I will try to briefly explain the solid design principle. If you are interested in a more detailed version you can read my [blog entry](https://harun-sevinc.com/2021/10/the-solid-design-principles/) about it. SOLID is an acronym and stands for the individual design principles that were first put into writing in this form by Robert C. Martin.

The goal of SOLID is the production of software, which tolerates modifications, is easily understandable and which forms a basis of the components, which are used in many software systems

## SRP-Single Responsibility Principle

The Single Responsibility Principle (SRP) is probably the most misunderstood of the SOLID principles. According to Robert C. Martin, software developers tend to assume that each module should perform a single task. The principle of refactoring and splitting to the lowest level for functions with a large scope does exist, but this is not what is meant by SRP. In general, the description of SRP is:

There should never be more than one reason to modify a class.


However, since in most cases software is written for customers/stakeholders or users and the notion of classes is too specific at this point, the following statement by Robert C. Martin is recommended:

„A module should be responsible for one, and only one, actor“.
As an example, one could take a module that provides functions for different business areas. If there is a change in one business area such that the structure of the class needs to change, this could impact the part of the class that is needed by another part of the organization. This creates dependencies that can be blocking for software development. Thus, it would make sense to design classes and methods in such a way that only one actor is responsible for the requirements and adaptations.

With the SRP it concerns thus mainly functions and classes and their connection to actors, which create requirements.

⚡If you want to read more about that topic you can check out my [blog](https://www.harun-sevinc.com)
⭐ or follow me on [twitter](https://twitter.com/harsvnc)
{Insert Hacktoberfest 2021-Related Title Here}
Tags: hacktoberfest
Published: 2021-10-21 20:27:21

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->


### [Intro Heading]
<!-- If you are new to the DEV community, introduce yourself and share a bit about why you joined DEV and decided to participate in Hacktoberfest this year.  --> 

### Background

<!-- Are you brand new to open source? What about coding in general? Tell us about how you got here →

### Progress

<!-- Share a bit about where you’re at in your Hacktoberfest journey. What stage are you at? How has the process been?  -->

### Contributions

<!-- This is where you can list the contributions you made and explain why you chose the projects you did. Don’t forget to add links!  -->


### Reflections
<!-- Overall, how has your Hacktoberfest 2021 experience been? If you’re a first-timer, will you participate again? What have you learned? Have you made any interesting connections? What is your next step in open source?  -->
Now 0pen VS Code in Your Browser [RE#11]
Tags: article, productivity, coding, news
Published: 2021-10-21 21:28:39

---
title: Now 0pen VS Code in Your Browser [RE#11]
published: true
date: 2021-10-21 20:15:00 UTC
tags: article, productivity, coding, news
canonical_url: https://babakks.github.io/article/2021/10/21/re-011-now-open-vscode-in-your-browser.html
series: Regular Encounters
---

I’ve always dreamed of opening VS Code in my browser. That would really help me,since, out of my workplace, I’m usually using my tablet or mobile phone and so having a hard time reviewing/writing code just because I’m not sitting behind my laptop.

If contributed on the project, or tried to build and run it from the source code, you’ve probably seen VS Code’s intrinsic capability to run in a browser. Other than that, people would basically expect Electron based applications, like VS Code, natively run in a Chromium/Chrome instance. Some third-party services, like [StackBlitz](https://stackblitz.com) or [Gitpod](https://gitpod.io) are providing this feature for free. There are open source repositories as well; among them [`cdr/code-server`](https://github.com/cdr/code-server) and [`gitpod-io/open vscode-server`](https://github.com/gitpod-io/openvscode-server). But an official host was still missing, especially because of unavailability of VS Code’s rich extension marketplace for non-Microsoft builds, like these third-party altrnatives.

Now, things have changed. Just open [vscode.dev](https://vscode.dev) to see the **officially** hosted version of VS Code; lightweight but quite promising, functional and consistent with the desktop version.

Also, make sure to check the [blog post](https://code.visualstudio.com/blogs/2021/10/20/vscode-dev) to get familiar with the new cool shortcuts that accelerate your development in the new environment.

* * *

**_About Regular Encounters_**  
_I’ve decided to record my daily encounters with professional issues on a somewhat regular basis. Not all of them are equally important/unique/intricate, but are indeed practical, real, and of course,_ **_textually minimal._**
Cloud computing case study
Published: 2021-10-21 20:14:01

I am new to cloud and I have a case study. I don't know how to solve this one and what all cloud models do I need to use to fulfill the client's requirements. I also haven't got any help from my professor.


Can anyone help me please?

Here it goes..

Business Overview

CFL (Crypto File Logic) is a small company with SOHO offices based in the UK, Spain and the US. The company is start up and currently has around 30 employees.

They provide a secure encryption service for PII data of governmental organisations using blockchain technology.

They are currently using standalone servers for their datacentres with minimal compute systems, network and storage devices. 

The application is based in-house, however on occasions CFL has to sub-contract the application development to an external company due to the complexity of the software.   

CFL CHALLENGES

Due to a monumental increase in demand of blockchain services the company must rapidly expand. The company has won over £100mil in grants via various governments in different countries. The governmental organisations contractual agreement has enforced compliance with cloud services. The customer has also instructed that the systems and network are of the top specifications to compensate with the divergence over to quantum computing capabilities. 

The current systems in use would only be able to cover about 10% of the current demand from the customers. Applications must be deployed and updated regularly. Currently the systems have to be managed locally and due technical staff shortages this is difficult. 

The customers are already using cloud services and require an information exchange between them and the CFL once cloud migration is complete. 

CFL REQUIREMENTS

CFL have to migrate their systems and services to cloud infrastructure. CFL want to have the ability to rapidly expand or retract the services depending on the demand period. The main demand period falls between January and May during the time governments are reviewing their data.

CFL expect to start a new line of applications to cover new blockchain services as they are released, once the applications are developed CFL are proposing to deploy them via a 3rd party service provider.   

CFL expect to be able to manage their own proprietary application and infrastructure remotely. CFL must have the ability manage the resources and deploy them as and when necessary.  

Due to the type of data being encrypted it must be stored on reliable mediums. Low of the data may result in cancellation of the contracts with the customers. 

ASSIGNMENT REQUIREMENTS:-

You are to present a high level formal report of no more than 1500 words (appendices can be used if necessary), recommending which approaches/techniques can help CFL provide a quality solution with the given requirements and challenges.  You should suitably justify any recommendations made.
Day 36/100 Design System
Tags: 100daysofcode, 100daychallenge, codenewbie, programming
Published: 2021-10-21 20:13:10

Finished the first module of the course and I got the chance to make the last assignment. Applied what I learned and I got the results that was needed to proceed to the next lessons.

![numbers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cp5hbczbtdg19le52s6n.png)
Intro To MongoDB Realm with VueJS Ionic Framework And ViteJS Integrating Geospatial Queries In Google Maps
Tags: mongodb, ionic, googlemaps, javascript
Published: 2021-10-21 20:07:14



In this video, we add a new collection to the database that contains the various locations of Tesla Superchargers I have used in DC region. We then show how to do location-based [MongoDB geospatial queries](https://docs.mongodb.com/manual/geospatial-queries/) to find the data and render it to a Google Map integrated into the VueJS Application us the [Google Maps Javascript API](https://developers.google.com/maps/documentation/javascript/overview).

We do a simple proximity-based query looking for locations near a specific point; we get the point from the users location. We also do a more advanced query where we get the region/bounds displayed on the map and then find all locations that are within the region. We are implementing the "Find In Area" you find often in map based applications.


{% youtube kEqDNcvpAYw %}


>A lot of the video is centered around a Google Maps Component for VueJS applications that I built in a previous video series, here is the link to that series [Google Maps With VueJS & Ionic Framework](https://www.youtube.com/playlist?list=PL2PY2-9rsgl3aJ8TKPwNiK1YInBcPtoRY)

#### Helpful Links
- Intro To MongoDB Realm with VueJS Ionic Framework Video Series - [Link](https://youtube.com/playlist?list=PL2PY2-9rsgl1ZJFraZ02uJ5dQzsz79Gru)
- Google Maps With VueJS  & Ionic Video Series - [Link](https://www.youtube.com/playlist?list=PL2PY2-9rsgl3aJ8TKPwNiK1YInBcPtoRY)
- Google Maps Javascript API - [Link](https://developers.google.com/maps/documentation/javascript/overview)
- MongoDb Geospatial Queries - [Link](https://docs.mongodb.com/manual/geospatial-queries/)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W31U7HM)
The trick to making console.log play nice with complex objects
Tags: javascript, typescript, node, webdev
Published: 2021-10-21 20:03:24

`console.log` is useful in a lot of situations (although there are [usually better ways to debug](https://nodejs.org/en/docs/guides/debugging-getting-started/) if that's what you're doing).

In the browser `console.log` works well with objects, you can drill down as much as you need. But in Node.js, when you look at the output of a nested object, you'll often see this:

```javascript
$ console.log({a: {b: { c: {d: {}}}}})

{ a: { b: { c: [Object] } } }
```

**`d: {}` was replaced with `[Object]`. But why?**

It's because the command line / terminal doesn't have a nice UI for drilling down, so Node attempts to print up to three levels deep. Beyond three levels it just prints `[Object]`.

This is controlled by a variable in the node 'util' module, called `depth`, which defaults to `2`. You can set it yourself here:

```javascript
require('util').inspect.defaultOptions.depth = 0; // top level only, e.g.:
// { a: [Object] }
require('util').inspect.defaultOptions.depth = null; // print everything, e.g.: 
// {
//  a: { b: { c: { d: {} } } }
// }
```

It's not a great idea to change an underlying variable, as it might come back to bite later. So a cleaner way is to convert the JSON object to a `string` and log that. We can use node's built in `JSON` class and the `stringify` method:

```javascript
complexObject = {a: {b: { c: {d: {}}}}}
console.log(JSON.stringify(complexObject, null, 2))

// {
//   "a": {
//     "b": {
//       "c": {
//         "d": {}
//       }
//     }
//   }
// }
```
*Note that the 3rd parameter of `JSON.stringify`, Number `2`, controls the number of spaces of indentation, and the 2nd parameter can be used to filter or adjust the objects and properties shown.*

Now you can really see what's in those deep Objects.
Building a HTML to PDF API using Go and wkhtmltopdf
Tags: html, go, api, wkhtmltopdf
Published: 2021-10-21 19:49:20


> Generating PDFs in code is difficult. Many solutions revolve around unfamiliar proprietary APIs that require pixel perfect placement of text and images that can become a nightmare in the long run.
> 
> This tutorial uses HTML, CSS, and Go to achieve a lightweight, modern approach to dynamically creating and serving PDFs from an API endpoint.

## Introduction

This tutorial follows how our team replaced our exsting PDF generation system. The decision for us to use wkhtmltopdf was primarily driven by our use of Golang on the backend and the 
allure of keeping our services as small as possible.

I recognize some teams may be interested in a Chromium/Puppeteer approach to PDF's and [I've linked some helpful articles to get you started.](https://engineering.sharebuilder401k.com/posts/go-html-to-pdf/#puppeteer-help-links)

[Continue reading on the ShareBuilder 401k Blog ->](https://engineering.sharebuilder401k.com/posts/go-html-to-pdf/)

You can checkout the [template golang + go-wkhtmltopdf project](https://github.com/ShareBuilder-401k/html-to-pdf) if you'd like to skip straight to code.

---

Cheers,
Tony

<sup>Photo by <a href="https://unsplash.com/@fotowei?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Wei Zeng</a> on <a href="https://unsplash.com/s/photos/seattle?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
  </sup>