### Configure EC2 Instance and Start Services Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Connects to the instance via SSH, installs Docker and Docker Compose, clones the repository, and starts the services. ```bash # SSH to instance and set up Docker ssh -i sup3rs3cretmes5age-key.pem ec2-user@$INSTANCE_IP # On the EC2 instance: sudo yum update -y sudo yum install -y docker sudo service docker start sudo usermod -a -G docker ec2-user # Install Docker Compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose # Clone repository git clone https://github.com/algolia/sup3rS3cretMes5age.git cd sup3rS3cretMes5age # Start services docker-compose -f deploy/docker-compose.yml up -d ``` -------------------------------- ### Quick Start with Docker Compose Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Clone the repository and use the provided Makefile to start the application and Vault dev server. ```bash # Clone the repository git clone https://github.com/algolia/sup3rS3cretMes5age.git cd sup3rS3cretMes5age # Start with Docker Compose (recommended) make run # Access the application open http://localhost:8082 ``` -------------------------------- ### Setup and Build Commands Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Commands to clone the repository, download dependencies, and build the application binary. ```bash # Clone the repository git clone https://github.com/algolia/sup3rS3cretMes5age.git cd sup3rS3cretMes5age # Download dependencies go mod download # Build the binary go build -o sup3rs3cret cmd/sup3rS3cretMes5age/main.go ``` -------------------------------- ### Install Go Dependencies Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Command to download Go module dependencies. ```bash go mod download ``` -------------------------------- ### Start Vault Dev Server Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Command to start a Vault development server in a Docker container. ```bash docker run -d --name vault-dev -p 8200:8200 \ -e VAULT_DEV_ROOT_TOKEN_ID=supersecret \ hashicorp/vault:latest ``` -------------------------------- ### Local Build and Execution Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Manually start a Vault dev server and run the application binary with environment variables. ```bash # Start Vault dev server docker run -d --name vault-dev -p 8200:8200 \ -e VAULT_DEV_ROOT_TOKEN_ID=supersecret \ hashicorp/vault:latest # Build and run the application go build -o sup3rs3cret cmd/sup3rS3cretMes5age/main.go VAULT_ADDR=http://localhost:8200 \ VAULT_TOKEN=supersecret \ SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS=":8080" \ ./sup3rs3cret ``` -------------------------------- ### Install jq on various Linux/macOS Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Commands to install jq on Ubuntu/Debian, macOS, and CentOS/RHEL. Use the appropriate command for your system. ```bash # Ubuntu/Debian sudo apt-get install jq # macOS brew install jq # CentOS/RHEL sudo yum install jq ``` -------------------------------- ### Bash usage examples for `o` Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Shows how to use the Bash `o` function with a file, stdin, command output, and multiple files. ```bash # From file o secret.txt # From stdin echo "secret message" | o # From command output ps aux | o # Multiple files o file1.txt file2.txt ``` -------------------------------- ### Basic CLI usage examples Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Shows how to share a secret file, pipe command output, and share multiple files using the `o` command. The generated URL is single-use and self-destructs after viewing. ```bash # Share a secret file $ o secret-config.json https://your-domain.com/getmsg?token=abc123def456 # Share command output $ kubectl get secrets -o yaml | o https://your-domain.com/getmsg?token=xyz789uvw012 # Share multiple files $ o database.env api-keys.txt https://your-domain.com/getmsg?token=mno345pqr678 ``` -------------------------------- ### WSL-specific usage examples Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Shows how to use the WSL `o` function to share a Windows file and to automatically copy the result to the Windows clipboard. ```bash # Share a Windows file o /mnt/c/Users/username/secret.txt # Copy result to Windows clipboard automatically echo "secret" | o ``` -------------------------------- ### Install curl on various Linux Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Commands to install curl on Ubuntu/Debian and CentOS/RHEL. Use the appropriate command for your system. ```bash # Ubuntu/Debian sudo apt-get install curl # CentOS/RHEL sudo yum install curl ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Example docker-compose.yml file configuring the vault and supersecret services. ```yaml version: '3.2' services: vault: image: vault:latest container_name: vault environment: VAULT_DEV_ROOT_TOKEN_ID: root cap_add: - IPC_LOCK expose: - 8200 supersecret: build: ./ image: algolia/supersecretmessage:latest container_name: supersecret environment: VAULT_ADDR: http://vault:8200 VAULT_TOKEN: root SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS: ":80" SUPERSECRETMESSAGE_HTTPS_BINDING_ADDRESS: ":443" SUPERSECRETMESSAGE_HTTPS_REDIRECT_ENABLED: "true" SUPERSECRETMESSAGE_TLS_AUTO_DOMAIN: secrets.example.com ports: - "80:80" - "443:443" depends_on: - vault ``` -------------------------------- ### Retrieve Secret Message Example Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Example of retrieving a secret message using the token provided during creation. ```bash curl "http://localhost:8082/secret?token=s.abc123def456" ``` -------------------------------- ### Deploy Application with Helm and Ingress Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Install HashiCorp Vault, deploy the application using Helm, and configure an ALB Ingress for external access. ```bash # Add Vault Helm repository helm repo add hashicorp https://helm.releases.hashicorp.com helm repo update # Install Vault helm install vault hashicorp/vault \ --set "server.dev.enabled=true" \ --set "server.dev.devRootToken=supersecret" # Deploy sup3rS3cretMes5age using the provided Helm chart cd sup3rS3cretMes5age/deploy/charts/supersecretmessage # Update values.yaml for your configuration helm install sup3rs3cretmes5age . \ --set image.repository=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/sup3rs3cretmes5age \ --set image.tag=latest \ --set vault.address=http://vault:8200 \ --set vault.token=supersecret # Create ingress for external access kubectl apply -f - << EOF apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: sup3rs3cretmes5age-ingress annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip spec: rules: - http: paths: - path: / pathType: Prefix backend: service: name: sup3rs3cretmes5age port: number: 80 EOF ``` -------------------------------- ### Create Secret Message Examples Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Examples of creating secret messages using curl, including text-only, custom TTL, and file upload requests. ```bash # Text message curl -X POST -F 'msg=This is a secret' http://localhost:8082/secret # With custom TTL curl -X POST -F 'msg=Short-lived secret' -F 'ttl=1h' http://localhost:8082/secret # With file curl -X POST -F 'msg=Check this file' -F 'file=@secret.pdf' http://localhost:8082/secret ``` -------------------------------- ### Make commands for local development Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Use these Make targets to manage local services (Vault and App). 'make run' starts services, 'make logs' shows logs, 'make stop' stops services, and 'make clean' removes containers. ```bash make run # Start services (Vault + App) make logs # View logs make stop # Stop services make clean # Remove containers ``` -------------------------------- ### Get application URL for LoadBalancer service type Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/deploy/charts/supersecretmessage/templates/NOTES.txt When service type is LoadBalancer, notes that it may take a few minutes for the IP to be available, and provides commands to watch status and get the service IP. Uses kubectl to retrieve the load balancer ingress IP. ```shell NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "supersecretmessage.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "supersecretmessage.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}" }}") echo http://$SERVICE_IP:{{ .Values.service.port }} ``` -------------------------------- ### Docker Compose direct command Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Starts the application using Docker Compose with the provided compose file. The application runs on port 8082 in HTTP mode by default. ```bash docker compose -f deploy/docker-compose.yml up --build -d ``` -------------------------------- ### GET /health Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Health check endpoint that returns OK with HTTP 200 when the service is healthy. ```APIDOC ## GET /health ### Description Health check endpoint that returns OK with HTTP 200 when the service is healthy. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **body** (string) - The response body is "OK" #### Response Example ``` OK ``` ``` -------------------------------- ### Get application URL for ClusterIP service type Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/deploy/charts/supersecretmessage/templates/NOTES.txt When service type is ClusterIP, exports POD_NAME and CONTAINER_PORT, then prints a message and sets up port-forwarding to access the application locally. ```shell export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "supersecretmessage.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:80 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 80:$CONTAINER_PORT ``` -------------------------------- ### Get application URL for ingress-enabled deployments Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/deploy/charts/supersecretmessage/templates/NOTES.txt When ingress is enabled, prints the URL(s) based on the configured hosts and paths. Uses Helm templating to iterate over ingress hosts and paths, and adds 's' to http if TLS is enabled. ```helm {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} ``` -------------------------------- ### Retrieve Secret Message Response Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md The JSON response structure returned after a successful GET request to /secret. ```json { "msg": "This is a secret" } ``` -------------------------------- ### GET /secret Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Retrieves a secret message using the token obtained from POST /secret. After retrieval, the message and token are permanently deleted. ```APIDOC ## GET /secret ### Description Retrieves a secret message using the token obtained from POST /secret. After retrieval, the message and token are permanently deleted. ### Method GET ### Endpoint /secret ### Parameters #### Query Parameters - **token** (string) - Required - The token from POST response ### Request Example ```bash curl "http://localhost:8082/secret?token=s.abc123def456" ``` ### Response #### Success Response (200) - **msg** (string) - The secret message content #### Response Example ```json { "msg": "This is a secret" } ``` ### Notes After retrieval, the message and token are permanently deleted. Second attempts will fail. ``` -------------------------------- ### Get application URL for NodePort service type Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/deploy/charts/supersecretmessage/templates/NOTES.txt When service type is NodePort, exports NODE_PORT and NODE_IP using kubectl, then echoes the URL. Requires kubectl access to the cluster. ```shell export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "supersecretmessage.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT ``` -------------------------------- ### Build Binary Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Command to compile the project binary. ```bash go build -o sup3rs3cret cmd/sup3rS3cretMes5age/main.go ``` -------------------------------- ### Running Tests Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Commands to execute the test suite using Make or the Go toolchain. ```bash # Run all tests make test # Or directly with go go test ./... -v ``` -------------------------------- ### Create configuration file ~/.sup3rsecret Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Defines environment variables for the sup3rs3cretmes5age tool, including the server URL, clipboard copy option, and QR code display option. This file is sourced by the shell function to avoid hardcoding URLs. ```bash # ~/.sup3rsecret SUPERSECRET_URL="https://your-domain.com" SUPERSECRET_COPY_TO_CLIPBOARD=true SUPERSECRET_SHOW_QR=false ``` -------------------------------- ### Launch EC2 Instance for Docker Deployment Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Creates an EC2 key pair, launches a t3.small instance, and retrieves the public IP address for connection. ```bash # Create key pair aws ec2 create-key-pair \ --key-name sup3rs3cretmes5age-key \ --query 'KeyMaterial' \ --output text > sup3rs3cretmes5age-key.pem chmod 400 sup3rs3cretmes5age-key.pem # Launch EC2 instance export INSTANCE_ID=$(aws ec2 run-instances \ --image-id ami-0c55b159cbfafe1d0 \ --count 1 \ --instance-type t3.small \ --key-name sup3rs3cretmes5age-key \ --security-groups default \ --query 'Instances[0].InstanceId' \ --output text) # Get public IP export INSTANCE_IP=$(aws ec2 describe-instances \ --instance-ids $INSTANCE_ID \ --query 'Reservations[0].Instances[0].PublicIpAddress' \ --output text) ``` -------------------------------- ### Create VPC and Subnets Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Creates a VPC, an Internet Gateway, and public/private subnets across two availability zones, then configures routing for the public subnets. ```bash # Create VPC export VPC_ID=$(aws ec2 create-vpc \ --cidr-block 10.0.0.0/16 \ --query 'Vpc.VpcId' \ --output text) aws ec2 create-tags \ --resources $VPC_ID \ --tags Key=Name,Value=sup3rs3cretmes5age-vpc # Create Internet Gateway export IGW_ID=$(aws ec2 create-internet-gateway \ --query 'InternetGateway.InternetGatewayId' \ --output text) aws ec2 attach-internet-gateway \ --vpc-id $VPC_ID \ --internet-gateway-id $IGW_ID # Create public subnets in two AZs export PUBLIC_SUBNET_1=$(aws ec2 create-subnet \ --vpc-id $VPC_ID \ --cidr-block 10.0.1.0/24 \ --availability-zone ${AWS_REGION}a \ --query 'Subnet.SubnetId' \ --output text) export PUBLIC_SUBNET_2=$(aws ec2 create-subnet \ --vpc-id $VPC_ID \ --cidr-block 10.0.2.0/24 \ --availability-zone ${AWS_REGION}b \ --query 'Subnet.SubnetId' \ --output text) # Create private subnets export PRIVATE_SUBNET_1=$(aws ec2 create-subnet \ --vpc-id $VPC_ID \ --cidr-block 10.0.3.0/24 \ --availability-zone ${AWS_REGION}a \ --query 'Subnet.SubnetId' \ --output text) export PRIVATE_SUBNET_2=$(aws ec2 create-subnet \ --vpc-id $VPC_ID \ --cidr-block 10.0.4.0/24 \ --availability-zone ${AWS_REGION}b \ --query 'Subnet.SubnetId' \ --output text) # Create route table for public subnets export PUBLIC_RT=$(aws ec2 create-route-table \ --vpc-id $VPC_ID \ --query 'RouteTable.RouteTableId' \ --output text) aws ec2 create-route \ --route-table-id $PUBLIC_RT \ --destination-cidr-block 0.0.0.0/0 \ --gateway-id $IGW_ID # Associate public subnets with route table aws ec2 associate-route-table --subnet-id $PUBLIC_SUBNET_1 --route-table-id $PUBLIC_RT aws ec2 associate-route-table --subnet-id $PUBLIC_SUBNET_2 --route-table-id $PUBLIC_RT # Enable auto-assign public IPs for public subnets aws ec2 modify-subnet-attribute --subnet-id $PUBLIC_SUBNET_1 --map-public-ip-on-launch aws ec2 modify-subnet-attribute --subnet-id $PUBLIC_SUBNET_2 --map-public-ip-on-launch ``` -------------------------------- ### Create ECR Repositories and Authenticate Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Sets up the AWS environment variables, creates private ECR repositories for the application and Vault, and authenticates the Docker client with ECR. ```bash # Set your AWS region export AWS_REGION=us-east-1 export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) # Create ECR repositories aws ecr create-repository \ --repository-name sup3rs3cretmes5age \ --region $AWS_REGION aws ecr create-repository \ --repository-name vault \ --region $AWS_REGION # Get login token for ECR aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com ``` -------------------------------- ### Create Application Load Balancer Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Deploys an Application Load Balancer, retrieves its DNS name, and sets up a target group and listener for HTTP traffic. ```bash # Create Application Load Balancer export ALB_ARN=$(aws elbv2 create-load-balancer \ --name sup3rs3cretmes5age-alb \ --subnets $PUBLIC_SUBNET_1 $PUBLIC_SUBNET_2 \ --security-groups $ALB_SG \ --query 'LoadBalancers[0].LoadBalancerArn' \ --output text) # Get ALB DNS name export ALB_DNS=$(aws elbv2 describe-load-balancers \ --load-balancer-arns $ALB_ARN \ --query 'LoadBalancers[0].DNSName' \ --output text) echo "ALB DNS Name: $ALB_DNS" # Create target group export TARGET_GROUP_ARN=$(aws elbv2 create-target-group \ --name sup3rs3cretmes5age-tg \ --protocol HTTP \ --port 80 \ --vpc-id $VPC_ID \ --target-type ip \ --health-check-path / \ --health-check-interval-seconds 30 \ --health-check-timeout-seconds 5 \ --healthy-threshold-count 2 \ --unhealthy-threshold-count 3 \ --query 'TargetGroups[0].TargetGroupArn' \ --output text) # Create listener aws elbv2 create-listener \ --load-balancer-arn $ALB_ARN \ --protocol HTTP \ --port 80 \ --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN ``` -------------------------------- ### Plain HTTP Configuration Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Environment variables for running the service over plain HTTP. ```bash VAULT_ADDR=http://vault:8200 VAULT_TOKEN=root SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS=:80 ``` -------------------------------- ### Run with Docker Compose Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Recommended command to run the application locally using Docker Compose. ```bash make run ``` -------------------------------- ### Create Network ACL Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Initializes a new network ACL for the specified VPC. ```bash # Create network ACL export NACL_ID=$(aws ec2 create-network-acl \ --vpc-id $VPC_ID \ --query 'NetworkAcl.NetworkAclId' \ --output text) # Add rules as needed for your security requirements ``` -------------------------------- ### Build multi-platform Docker image Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Builds the Docker image for multiple architectures (linux/amd64, linux/arm64) with SBOM and provenance attestations. This command appears twice in the documentation, once under 'Docker Image' and once under 'AWS Deployment'. ```bash # Build for multiple architectures make image # Builds: linux/amd64, linux/arm64 with SBOM and provenance ``` -------------------------------- ### Deploy with Helm Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Deploy the application to Kubernetes using the provided Helm chart with Vault configuration. ```bash helm install supersecret ./deploy/charts/supersecretmessage \ --set config.vault.address=http://vault.default.svc.cluster.local:8200 \ --set config.vault.token_secret.name=vault-token ``` -------------------------------- ### Run Quality Checks Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Commands to format, vet, lint, and test the codebase before submitting a pull request. ```bash gofmt -s -l . go vet ./... golangci-lint run --timeout 300s make test ``` -------------------------------- ### Run App with Local Vault Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Command to run the application binary configured to connect to the local Vault instance. ```bash VAULT_ADDR=http://localhost:8200 \ VAULT_TOKEN=supersecret \ SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS=":8080" \ ./sup3rs3cret ``` -------------------------------- ### Project Structure Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Overview of the project directory layout and core components. ```text . ├── cmd/sup3rS3cretMes5age/ # Application entry point │ └── main.go # (23 lines) ├── internal/ # Core business logic │ ├── config.go # Configuration (77 lines) │ ├── handlers.go # HTTP handlers (88 lines) │ ├── server.go # Server setup (94 lines) │ └── vault.go # Vault integration (174 lines) ├── web/static/ # Frontend assets │ ├── index.html # Message creation page │ ├── getmsg.html # Message retrieval page │ ├── application.css # Styling │ └── clipboard-2.0.11.min.js ├── deploy/ # Deployment configs │ ├── Dockerfile # Multi-stage build │ ├── docker-compose.yml # Local dev stack │ └── charts/ # Helm chart └── Makefile # Build automation ``` -------------------------------- ### Enable VPC Flow Logs Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Configures VPC Flow Logs to monitor traffic and send logs to CloudWatch. ```bash aws ec2 create-flow-logs \ --resource-type VPC \ --resource-ids $VPC_ID \ --traffic-type ALL \ --log-destination-type cloud-watch-logs \ --log-group-name VPCFlowLogs ``` -------------------------------- ### Manual TLS Configuration Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Environment variables for configuring manual TLS using specific certificate and key file paths. ```bash VAULT_ADDR=http://vault:8200 VAULT_TOKEN=root SUPERSECRETMESSAGE_HTTPS_BINDING_ADDRESS=:443 SUPERSECRETMESSAGE_TLS_CERT_FILEPATH=/mnt/ssl/cert_secrets.example.com.pem SUPERSECRETMESSAGE_TLS_CERT_KEY_FILEPATH=/mnt/ssl/key_secrets.example.com.pem ``` -------------------------------- ### Auto TLS Configuration Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Environment variables for enabling automatic TLS via Let's Encrypt. ```bash VAULT_ADDR=http://vault:8200 VAULT_TOKEN=root SUPERSECRETMESSAGE_HTTPS_BINDING_ADDRESS=:443 SUPERSECRETMESSAGE_TLS_AUTO_DOMAIN=secrets.example.com ``` -------------------------------- ### Fish-specific features for `o` Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Shows how to use Fish's command substitution and pipe-to-variable features with the `o` function to capture the generated URL. ```fish # With Fish's command substitution set secret_url (echo "my secret" | o) echo "Share this URL: $secret_url" # Using Fish's pipe to variable echo "secret data" | o | read -g secret_link ``` -------------------------------- ### Code Quality and Analysis Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Commands for formatting, linting, and performing static analysis on the codebase. ```bash # Format code gofmt -s -w . # Lint golangci-lint run --timeout 300s # Static analysis go vet ./... ``` -------------------------------- ### Build and Push Docker Images to ECR Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Clones the repository, builds the application image, tags it for ECR, and pushes both the application and Vault images to the private registry. ```bash # Clone and build the application git clone https://github.com/algolia/sup3rS3cretMes5age.git cd sup3rS3cretMes5age # Build the application image (with network=host to handle certificate issues) docker build --network=host -f deploy/Dockerfile -t sup3rs3cretmes5age . # Tag for ECR docker tag sup3rs3cretmes5age:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/sup3rs3cretmes5age:latest # Push to ECR docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/sup3rs3cretmes5age:latest # Pull and push Vault image to your ECR docker pull hashicorp/vault:latest docker tag hashicorp/vault:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/vault:latest docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/vault:latest ``` -------------------------------- ### Create EKS Cluster with eksctl Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Use eksctl to provision an EKS cluster with managed node groups. Prerequisites include kubectl, helm, and eksctl. ```bash # Install required tools # - kubectl # - helm # - eksctl (recommended for cluster creation) # Create EKS cluster eksctl create cluster \ --name sup3rs3cretmes5age \ --region $AWS_REGION \ --nodegroup-name standard-workers \ --node-type t3.medium \ --nodes 2 \ --nodes-min 1 \ --nodes-max 4 \ --managed ``` -------------------------------- ### Create ECS Service Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Defines the service configuration and creates the ECS service using the Fargate launch type. ```bash # Create ECS service cat > service-definition.json << EOF { "serviceName": "sup3rs3cretmes5age-service", "cluster": "sup3rs3cretmes5age-cluster", "taskDefinition": "sup3rs3cretmes5age", "desiredCount": 1, "launchType": "FARGATE", "networkConfiguration": { "awsvpcConfiguration": { "subnets": ["$PRIVATE_SUBNET_1", "$PRIVATE_SUBNET_2"], "securityGroups": ["$ECS_SG"], "assignPublicIp": "DISABLED" } }, "loadBalancers": [ { "targetGroupArn": "$TARGET_GROUP_ARN", "containerName": "supersecret", "containerPort": 80 } ] } EOF aws ecs create-service --cli-input-json file://service-definition.json ``` -------------------------------- ### Register ECS Task Definition Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Creates the task definition JSON file, sets up the CloudWatch log group, and registers the task definition with ECS. ```bash cat > task-definition.json << EOF { "family": "sup3rs3cretmes5age", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "512", "memory": "1024", "executionRoleArn": "$TASK_EXECUTION_ROLE_ARN", "containerDefinitions": [ { "name": "vault", "image": "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/vault:latest", "essential": true, "environment": [ { "name": "VAULT_DEV_ROOT_TOKEN_ID", "value": "supersecret" } ], "portMappings": [ { "containerPort": 8200, "protocol": "tcp" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/sup3rs3cretmes5age", "awslogs-region": "$AWS_REGION", "awslogs-stream-prefix": "vault" } }, "linuxParameters": { "capabilities": { "add": ["IPC_LOCK"] } } }, { "name": "supersecret", "image": "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/sup3rs3cretmes5age:latest", "essential": true, "dependsOn": [ { "containerName": "vault", "condition": "START" } ], "environment": [ { "name": "VAULT_ADDR", "value": "http://localhost:8200" }, { "name": "VAULT_TOKEN", "value": "supersecret" }, { "name": "SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS", "value": ":80" } ], "portMappings": [ { "containerPort": 80, "protocol": "tcp" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/sup3rs3cretmes5age", "awslogs-region": "$AWS_REGION", "awslogs-stream-prefix": "supersecret" } } } ] } EOF # Create CloudWatch log group aws logs create-log-group --log-group-name /ecs/sup3rs3cretmes5age # Register task definition aws ecs register-task-definition --cli-input-json file://task-definition.json ``` -------------------------------- ### Configure HTTPS Listener Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Requests an SSL certificate via ACM and creates an HTTPS listener for the load balancer. ```bash # Request SSL certificate (replace with your domain) export DOMAIN_NAME="secrets.yourdomain.com" export CERT_ARN=$(aws acm request-certificate \ --domain-name $DOMAIN_NAME \ --validation-method DNS \ --query 'CertificateArn' \ --output text) echo "Certificate ARN: $CERT_ARN" echo "Complete DNS validation in ACM console, then continue..." # After DNS validation is complete, create HTTPS listener aws elbv2 create-listener \ --load-balancer-arn $ALB_ARN \ --protocol HTTPS \ --port 443 \ --certificates CertificateArn=$CERT_ARN \ --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN ``` -------------------------------- ### Create ECS Cluster Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Initializes a new ECS cluster named sup3rs3cretmes5age-cluster. ```bash # Create ECS cluster aws ecs create-cluster --cluster-name sup3rs3cretmes5age-cluster ``` -------------------------------- ### Auto TLS with HTTP to HTTPS Redirection Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Environment variables for enabling Auto TLS with automatic HTTP to HTTPS redirection. ```bash VAULT_ADDR=http://vault:8200 VAULT_TOKEN=root SUPERSECRETMESSAGE_HTTP_BINDING_ADDRESS=:80 SUPERSECRETMESSAGE_HTTPS_BINDING_ADDRESS=:443 SUPERSECRETMESSAGE_HTTPS_REDIRECT_ENABLED=true SUPERSECRETMESSAGE_TLS_AUTO_DOMAIN=secrets.example.com ``` -------------------------------- ### Configure ECS Auto Scaling Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Register a scalable target and apply a target tracking scaling policy to manage service capacity automatically. ```bash # Register scalable target aws application-autoscaling register-scalable-target \ --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/sup3rs3cretmes5age-cluster/sup3rs3cretmes5age-service \ --min-capacity 1 \ --max-capacity 10 # Create scaling policy aws application-autoscaling put-scaling-policy \ --policy-name sup3rs3cretmes5age-scaling-policy \ --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/sup3rs3cretmes5age-cluster/sup3rs3cretmes5age-service \ --policy-type TargetTrackingScaling \ --target-tracking-scaling-policy-configuration file://scaling-policy.json ``` -------------------------------- ### Update ECS cluster to use Fargate Spot Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Use this command to enable Fargate Spot capacity providers for non-production environments to reduce costs. ```bash # Update service to use Fargate Spot aws ecs put-cluster-capacity-providers \ --cluster sup3rs3cretmes5age-cluster \ --capacity-providers FARGATE FARGATE_SPOT ``` -------------------------------- ### Test function with simple message Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Send a test message to your function using echo and the 'o' command. You should receive a URL to verify the message appears and self-destructs. ```bash echo "test message" | o ``` -------------------------------- ### Fish shell function for `o` Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Add this function to `~/.config/fish/config.fish` to create a `o` command that reads from stdin or files, posts to the sup3rS3cretMes5age API, and prints the resulting URL. Includes error handling. ```fish function o set -l url "https://your-domain.com" if test (count $argv) -eq 0 # Read from stdin set response (curl -sF 'msg=<-' "$url/secret") else # Read from files set response (cat $argv | curl -sF 'msg=<-' "$url/secret") end if test $status -eq 0 echo $response | jq -r .token | awk -v url="$url" '{print url"/getmsg?token="$1}' else echo "Error: Failed to create secure message" >&2 return 1 end end ``` -------------------------------- ### ECS Debugging and Troubleshooting Commands Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md A collection of commands to check service status, view logs, verify target health, and execute commands inside a container. ```bash # Check ECS service status aws ecs describe-services \ --cluster sup3rs3cretmes5age-cluster \ --services sup3rs3cretmes5age-service # View logs aws logs tail /ecs/sup3rs3cretmes5age --follow # Check target group health aws elbv2 describe-target-health \ --target-group-arn $TARGET_GROUP_ARN # Test internal connectivity aws ecs execute-command \ --cluster sup3rs3cretmes5age-cluster \ --task \ --container supersecret \ --interactive \ --command "/bin/sh" ``` -------------------------------- ### Create Security Groups Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Configures security groups for the Application Load Balancer and ECS tasks, including ingress rules for HTTP, HTTPS, and Vault traffic. ```bash # Security group for Application Load Balancer export ALB_SG=$(aws ec2 create-security-group \ --group-name sup3rs3cretmes5age-alb-sg \ --description "Security group for sup3rs3cretmes5age ALB" \ --vpc-id $VPC_ID \ --query 'GroupId' \ --output text) # Allow HTTP and HTTPS traffic to ALB aws ec2 authorize-security-group-ingress \ --group-id $ALB_SG \ --protocol tcp \ --port 80 \ --cidr 0.0.0.0/0 aws ec2 authorize-security-group-ingress \ --group-id $ALB_SG \ --protocol tcp \ --port 443 \ --cidr 0.0.0.0/0 # Security group for ECS tasks export ECS_SG=$(aws ec2 create-security-group \ --group-name sup3rs3cretmes5age-ecs-sg \ --description "Security group for sup3rs3cretmes5age ECS tasks" \ --vpc-id $VPC_ID \ --query 'GroupId' \ --output text) # Allow traffic from ALB to ECS tasks aws ec2 authorize-security-group-ingress \ --group-id $ECS_SG \ --protocol tcp \ --port 80 \ --source-group $ALB_SG # Allow Vault communication between tasks aws ec2 authorize-security-group-ingress \ --group-id $ECS_SG \ --protocol tcp \ --port 8200 \ --source-group $ECS_SG ``` -------------------------------- ### CLI Integration for Shell Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Add the provided shell function to your ~/.bashrc or ~/.zshrc to enable quick secret sharing from the command line. ```bash # Add to your ~/.bashrc or ~/.zshrc o() { cat "$@" | curl -sF 'msg=<-' https://your-domain.com/secret | jq -r .token | awk '{print "https://your-domain.com/getmsg?token="$1}'; } # Usage echo "secret message" | o o secret-file.txt ``` -------------------------------- ### Add QR code generation to shell function Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Extends the shell function to generate a QR code for the secret URL when the SUPERSECRET_SHOW_QR environment variable is set to true and the qrencode command is available. The QR code is displayed in ANSI format. ```bash o() { # ... existing function logic ... local secret_url="$url/getmsg?token=$token" echo "$secret_url" # Generate QR code if requested if [ "$SUPERSECRET_SHOW_QR" = "true" ] && command -v qrencode >/dev/null 2>&1; then echo "QR Code:" qrencode -t ANSIUTF8 "$secret_url" fi } ``` -------------------------------- ### Enable HTTPS Redirect in Task Definition Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/AWS_DEPLOYMENT.md Configures the task definition to enable HTTPS redirection. ```json { "name": "SUPERSECRETMESSAGE_HTTPS_REDIRECT_ENABLED", "value": "true" } ``` -------------------------------- ### Manual End-to-End Validation Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Commands to verify the self-destructing message lifecycle using curl and jq. ```bash TOKEN=$(curl -X POST -s -F 'msg=test secret message' http://localhost:8080/secret | jq -r .token) curl -s "http://localhost:8080/secret?token=$TOKEN" | jq . curl -s "http://localhost:8080/secret?token=$TOKEN" | jq . ``` -------------------------------- ### WSL Bash function for `o` Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Add this function to `~/.bashrc` in WSL (Ubuntu/Debian) to create a `o` command that handles Windows line endings with `dos2unix` and optionally copies the URL to the Windows clipboard using `clip.exe`. ```bash o() { local url="https://your-domain.com" local response # Handle Windows line endings if [ $# -eq 0 ]; then response=$(curl -sF 'msg=<-' "$url/secret") else response=$(cat "$@" | dos2unix | curl -sF 'msg=<-' "$url/secret") fi if [ $? -eq 0 ]; then token=$(echo "$response" | jq -r .token) echo "$url/getmsg?token=$token" # Optional: Copy to Windows clipboard if command -v clip.exe >/dev/null 2>&1; then echo "$url/getmsg?token=$token" | clip.exe echo "(URL copied to Windows clipboard)" fi else echo "Error: Failed to create secure message" >&2 return 1 fi } ``` -------------------------------- ### Conventional Commit Format Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md The required format for commit messages using Conventional Commits. ```text type(scope): description ``` -------------------------------- ### Cleanup Vault Container Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CONTRIBUTING.md Command to stop and remove the Vault development container. ```bash docker stop vault-dev && docker rm vault-dev ``` -------------------------------- ### Bash shell function for `o` Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Add this function to `~/.bashrc` to create a `o` command that reads from stdin or files, posts to the sup3rS3cretMes5age API, and prints the resulting URL. Requires `curl` and `jq`. ```bash o() { if [ $# -eq 0 ]; then # Read from stdin if no arguments curl -sF 'msg=<-' https://your-domain.com/secret | jq -r .token | awk '{print "https://your-domain.com/getmsg?token="$1}' else # Read from files cat "$@" | curl -sF 'msg=<-' https://your-domain.com/secret | jq -r .token | awk '{print "https://your-domain.com/getmsg?token="$1}' fi } ``` -------------------------------- ### POST /secret Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/README.md Creates a secret message. Accepts multipart/form-data with the message content, optional TTL, and optional file upload. Returns a token for retrieval. ```APIDOC ## POST /secret ### Description Creates a secret message. Accepts multipart/form-data with the message content, optional TTL, and optional file upload. Returns a token for retrieval. ### Method POST ### Endpoint /secret ### Parameters #### Request Body (multipart/form-data) - **msg** (string) - Required - The secret message content - **ttl** (string) - Optional - Time-to-live (default: 48h, max: 168h) - **file** (file) - Optional - File to upload (max 50MB) ### Request Example ```bash # Text message curl -X POST -F 'msg=This is a secret' http://localhost:8082/secret # With custom TTL curl -X POST -F 'msg=Short-lived secret' -F 'ttl=1h' http://localhost:8082/secret # With file curl -X POST -F 'msg=Check this file' -F 'file=@secret.pdf' http://localhost:8082/secret ``` ### Response #### Success Response (200) - **token** (string) - The token for retrieving the secret - **filetoken** (string) - If file uploaded, token for file retrieval - **filename** (string) - If file uploaded, original filename #### Response Example ```json { "token": "s.abc123def456", "filetoken": "s.xyz789uvw012", "filename": "secret.pdf" } ``` ``` -------------------------------- ### Modify shell function to source config Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Updates the shell function 'o' to load the configuration file and set a default URL. This allows the function to use the configured URL or fall back to a default. ```bash o() { # Load config [ -f ~/.sup3rsecret ] && source ~/.sup3rsecret local url="${SUPERSECRET_URL:-https://your-domain.com}" # ... rest of function } ``` -------------------------------- ### Reload shell configuration Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Reload your shell configuration after adding a function to your config. Replace the comment with your actual shell config file. ```bash # Reload your shell configuration source ~/.bashrc # or ~/.zshrc, ~/.config/fish/config.fish ``` -------------------------------- ### Send message with curl ignoring SSL Source: https://github.com/algolia/sup3rs3cretmes5age/blob/master/CLI.md Use curl with -k to ignore SSL certificate errors for self-signed certificates. Not recommended for production. ```bash # For self-signed certificates (NOT recommended for production) curl -k -sF 'msg=<-' https://your-domain.com/secret ```