Skip to content

Instantly share code, notes, and snippets.

@mtougeron
mtougeron / CAPA.md
Last active January 23, 2024 21:22
Notes for importing managed clusters into Cluster API

WARNING: This hasn't been tested extensively outside of my environment. Your mileage may vary.

Assumptions:

  • Any security group modifications or creation that CAPA does that's not specifically flagged below are acceptable for a brief disruption when modified
  • This is valid as of CAPA 2.0.2. This may not work with new versions (e.g., the steps were different pre-2.x and it was easier to import even the VPC itself pre-2.x)

Importing CAPA Cluster (using BYO VPC):

  • Make sure AWSManagedControlPlane.spec.eksClusterName matches the EKS cluster name
  • Optionally set AWSManagedControlPlane.spec.network.securityGroupOverrides.controlplane to match the security group you have on the EKS controlplane. If you have extra security groups I haven't been able to figure out how to import those into CAPA but they stay attached to the EKS cluster and are just ignored by CAPA
  • Set the VPC information according to the BYO VPC specs https://cluster-api-aws.sigs.k8s.io/topics/bring-your-own-aws-infrastructure.html#configur
@jappievw
jappievw / boto3_session_management_and_assume_role.py
Last active July 22, 2023 18:43
Boto3 Management Session with Refreshable Assume Role
from os import getenv
from boto3 import Session
from util import make_refreshable_assume_role_session
def example():
management_session = Session(aws_access_key_id=getenv('AWS_ACCESS_KEY_ID'),
aws_secret_access_key=getenv('AWS_SECRET_ACCESS_KEY'))
assume_role_params = dict(
WITH btree_index_atts AS (
SELECT nspname, relname, reltuples, relpages, indrelid, relam,
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum,
indexrelid as index_oid
FROM pg_index
JOIN pg_class ON pg_class.oid=pg_index.indexrelid
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
JOIN pg_am ON pg_class.relam = pg_am.oid
WHERE pg_am.amname = 'btree'
),