Skip to content

Instantly share code, notes, and snippets.

@nbcchen
nbcchen / README.md
Last active April 9, 2025 04:07
circleci

Separate Serverless build and deploy.

Steps

Why?

  1. Easier to troubleshoot
  2. There's a known issue with serverless-plugin-typescript building too slowly. The more functions per stack, the slower the build is. If deployment fails because of some IAM permission issues, we can re-run from failed and save some time on the build. The built artifacts are already cached using save_cache, we just need to load them
  3. In the future we can integrate with an artifactory (e.g. JFrog etc)
const brands = ["Toyota", "Jeep", "Mazda", 'Volvo', 'Ford'].map(brand => {
const url = new URL(
"https://www.atlanticchevrolet.com"
);
url.searchParams.append("compositeType", "preowned");
url.searchParams.append("make", brand);
url.pathname = '/all-inventory/index.htm';
console.log(url.href);
});
@nbcchen
nbcchen / jenkins-users.js
Created November 5, 2024 15:48
list jenkins users
const users = Array.from($('#people > tbody').children).filter(
/**
* @param {HTMLTableRowElement} tr
*/
tr => tr.id
).map(
/**
* @param {HTMLTableRowElement} tr
*/
tr => {
@nbcchen
nbcchen / method-1.tf
Created October 24, 2024 02:01
Construct ECR image
data "aws_ecr_repository" "repo" {
name = var.repository_name
}
locals {
image = "${data.aws_ecr_repository.repo.repository_url}:${var.image_tag}"
}
@nbcchen
nbcchen / Dockerfile
Last active August 12, 2024 16:13
Flask
FROM python:3.8-alpine
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
# copy every content from the local file to the image
COPY . /app
# configure the container to run in an executed manner
ENTRYPOINT [ "python" ]
@nbcchen
nbcchen / read-api-gateway.tf
Last active July 8, 2024 12:27
Read different stuff from Serverless stack in Terraform
variable "env" {
type = string
}
# Read API Gateway API
# The name is always {stageName}-{serviceName}, unless apiName is specified
# Doesn't work with nested stacks created by serverless-plugin-split-stacks
# https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml#api-gateway-v1-rest-api
data "aws_api_gateway_rest_api" "rest_api" {
functions:
function1:
tracing: Active
environment:
AWS_LAMBDA_EXEC_WRAPPER: '/opt/otel-handler'
layers:
- !Sub arn:aws:lambda:${AWS::Region}:901920570463:layer:aws-otel-nodejs-0-23-0:1 # https://github.com/aws-observability/aws-otel-lambda#aws-managed-opentelemetry-lambda-layers
foreach($_ in [System.TimeZoneInfo]::GetSystemTimeZones()){if($_.Id.StartsWith('Greenwich') -or $_.Id.StartsWith('GMT')){ echo $_ }}