Skip to content

Instantly share code, notes, and snippets.

@pmkuny
pmkuny / semantic-commit-messages.md
Last active March 9, 2023 19:12 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

# 1. Create IAM Policy
self.efs_csi_policy = iam.Policy(
self,
"EfsCsiPolicy",
statements=[
iam.PolicyStatement(
actions=[
"elasticfilesystem:DescribeAccessPoints",
"elasticfilesystem:DescribeFileSystems"
],
@pmkuny
pmkuny / gist:4d7c3db2a82faf3bc6bd22d43b2b2187
Last active February 19, 2022 04:19
Python Logging Boilerplate
# Import our logging package
import logging
# Set our default Logging Level to WARNING and override if an environment variable exists. The second argument in environ.get will set the EV if not set already. It is the default value.
LOGLEVEL=os.environ.get('LOGLEVEL', 'WARNING').upper()
logging.basicConfig(level=LOGLEVEL)
# Print some logging information to the DEBUG loglevel.
logging.debug("What I learned in boating school is")
Notes from: https://ben11kehoe.medium.com/boto3-sessions-and-why-you-should-use-them-9b094eb5ca8e
API Session != normal ideas of "session"
* API Sessions is a set of region + credentials, at base. If you're using a different region, or different credentials, you should be using a different session within Boto
The configuration chain is listed here in the docs: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html
aws iam list-virtual-mfa-devices | grep UserName | sort | cut -f 2 -d:
@pmkuny
pmkuny / eks.md
Created September 18, 2021 02:44
Kubernetes Notes

EKS Specific - For multi-AZ deployment, storage should be handled through EFS Dynamic Provisioning, using the EFS CSI driver. Only EFS can be used, as EBS volumes cannot be attached to multiple nodes.

aws iam list-roles --query "Roles[?contains(RoleName,'Admin')]"
@pmkuny
pmkuny / cloudformation.md
Last active February 12, 2022 19:42
General Thoughts on CloudFormation

For future reference:

  • Stack exports are available to other stacks and can be imported by Fn:ImportValue - I tend to have a ton of exports for several stacks, because each Fn:GettAtt needs to be its own export. Since Stack Layering is preferred over Nested Stacks, there are a ton of exports with each Template.
  • When talking about IAM, and referencing IAM policies, an AWS-Managed IAM policy can be referenced, but you can also create a customer-managed policy with AWS::IAM::ManagedPolicy - this is in contrast to AWS::IAM::Policy, which is actually used to define an in-line policy. Before reading more about, I was thinking that ManagedPolicy referred to the AWS-managed ones, but that's not the case.
  • Jinja2 for generatiing CloudFormation templates - need to experiment with this more, will make handling JSON policies (for IAM) easier. Really what I want is the ability to store JSON as separate files, in a code repository.
  • As an aside to the above, using a (limited) nested stack runs into the pro
@pmkuny
pmkuny / generator.py
Created May 31, 2021 00:57
random-name-py-generator
import uuid
def generate_name(name):
while True:
yield name + "-" + str(uuid.uuid4())
response = generate_name("test")
print(next(response))
@pmkuny
pmkuny / playbook.yml
Last active May 6, 2021 01:13
Ansible Bootstrap Development
---
- name: bootstrap
hosts: localhost
connection: local
tasks:
- name: Update System
yum:
name: "*"
state: latest
- name: Install tools