Skip to content

Instantly share code, notes, and snippets.

View sayadi's full-sized avatar

Mohamed Al Sayadi sayadi

View GitHub Profile
@sayadi
sayadi / .1-Instructions.md
Last active January 30, 2023 16:34
How to SSH to an AWS EC2 Instance Running Linux from a CircleCI 2 Build

How to SSH to an AWS EC2 Instance Running Linux from a CircleCI 2 Build

The Problem

If you use EC2 to host your application, and a tool like CircleCI to automate the deployment of new versions of your application, chances are, you've run into the problem of Circle not being able to SSH into your servers.

The problem is Circle could change the public IP of your runner for every new Build which prevents it from being able to access (SSH) the EC2 Instance. Unfortunately, Circle is not able to provide a list of public IP addresses to whitelist on a Security Group attached to the EC2 Instance. More on this here: https://discuss.circleci.com/t/circleci-source-ip/1202

version: 2
general:
branches:
only:
- dev
- staging
- prod
jobs:
build:
docker:
@sayadi
sayadi / edit-coredns.tf
Created July 21, 2021 09:34
Running the EKS CoreDNS deployment on Fargate when using the Terraform EKS module
# By default, the AWS EKS API creates the coredns deployment template with an annotation
# `eks.amazonaws.com/compute-type` equal to `ec2`. This prevents coredns pods from running on Fargate.
# Removing this annotation fixes the issue.
# More on: https://github.com/hashicorp/terraform-provider-aws/issues/11327
resource "null_resource" "edit_coredns" {
provisioner "local-exec" {
environment = {
KUBECONFIG = module.eks.kubeconfig_filename
CLUSTER_NAME = local.cluster_name
}
@RestController
@RequestMapping("/properties")
public class PropertyController {
private final Environment environment;
@Autowired
public PropertyController(
Environment environment) {
prop2=Production-specific value for prop2.
prop3=Production-specific value for prop3.
spring.profiles.include=non-prod
prop3=Staging-specific value for prop3.
spring.profiles.include=non-prod
prop3=Development-specific value for prop3.
prop2=Non-production-specific value for prop2.
prop1=This is a shared value across all profiles for prop1.
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profile.from.maven/>
</properties>
<dependencies>