Skip to content

Instantly share code, notes, and snippets.

View pkutaj's full-sized avatar

pavol kutaj pkutaj

View GitHub Profile
@pkutaj
pkutaj / TF1-04.08-Working-with-State-Data2.md
Created October 5, 2023 08:12
TF1-04.08-Working-with-State-Data2.md
STEP CONFIG_FILE STATE_FILE TARGET_ENV(AWS)
manual aws_instance.nginx aws_instance.nginx = id-314122 destroy > no resource
apply #1 aws_instance.nginx aws_instance.nginx = id-314122 add > id-8675366
apply #2 aws_instance.nginx change > aws_instance.nginx = id-8675366 id-8675366
@pkutaj
pkutaj / TF1-04.08-Working-with-State-Data1.md
Created October 5, 2023 08:11
TF1-04.08-Working-with-State-Data1.md
STEP CONFIG_FILE STATE_FILE TARGET_ENV(AWS)
manual add > aws_instance.nginx empty no resource
apply #1 aws_instance.nginx empty add id-314122
apply #2 aws_instance.nginx add aws_instance.nginx = id-314122 id-314122
@pkutaj
pkutaj / 2023-05-29-Explaining-Permission-Boundaries-in-AWS.md
Created August 16, 2023 14:03
2023-05-29-Explaining-Permission-Boundaries-in-AWS.md
Policy Type Description
1. Identity-based Attached to an IAM identity (user, group, or role). Specifies what that identity can do.
2. Resource-based Attached to a resource. Specifies who has access to the resource and what actions they can perform on it.
3. Permissions Boundary Uses a managed policy to set the maximum permissions that an identity-based policy can grant to an IAM entity.
4. Organizations SCPs Defines the maximum permissions for account members of an organization or organizational unit (OU).
5. ACLs Controls which principals in sother accounts can access the resource to which the ACL is attached.
6. Session Policies Passes ad
@pkutaj
pkutaj / 2023-07-26-Explaining-DBT-and-Analytics-Engineering-compared-to-Typical-Datamodeling-Practices.md
Created July 26, 2023 08:30
2023-07-26-Explaining-DBT-and-Analytics-Engineering-compared-to-Typical-Datamodeling-Practices.md
Engineering Practice Typical Practice
Modular SQL Monolithic SQL
Data testing No data testing
Version control No version control
Documentation No documentation
Collaboration Limited collaboration
@pkutaj
pkutaj / 2023-07-24-Explaining-CNAME-DNS-Record.md
Created July 24, 2023 12:09
2023-07-24-Explaining-CNAME-DNS-Record.md
Field Value
Alias pavol.kutaj.com
TTL 3600
Class IN
Type CNAME
Target pkutaj.github.io
@pkutaj
pkutaj / 2023-07-21-How-to-Fix-422-Client-Error--Unprocessable-Entity-when-using-json-parameter-of-Request-Python-Module.md
Created July 21, 2023 02:42
2023-07-21-How-to-Fix-422-Client-Error--Unprocessable-Entity-when-using-json-parameter-of-Request-Python-Module.md
Code Explanation
with open("temp_schema.json", mode="rt", encoding="utf-8") as patched_schema: Opens the file in read mode with UTF-8 encoding
schema_to_patch = patched_schema.read() Reads the contents of the file into a string
schema_patcher_http_requestor.make_iglu_request(...) Calls the make_iglu_request function
res = request_func(...) Makes an HTTP request using the requests library
json=schema_to_patch Passes the conte
@pkutaj
pkutaj / 2023-07-20-How-to-Get-Custom-Tags-with-AWS-CLI.md
Created July 20, 2023 08:58
2023-07-20-How-to-Get-Custom-Tags-with-AWS-CLI.md
Command Description
aws ec2 describe-tags Lists custom tags for EC2 resources
aws resourcegroupstaggingapi get-resources Returns all tagged or previously tagged resources
--tag-filters Key=system,Values=foo* Filters output by tag key and value
@pkutaj
pkutaj / 2023-07-20-Explaining-AWS-Security-Groups-on-the-Example-of-Terraform-Drift.md
Created July 20, 2023 07:53
2023-07-20-Explaining-AWS-Security-Groups-on-the-Example-of-Terraform-Drift.md
Change Description
Update The aws_security_group resource named public_sg in the module.redshift.module.cluster module will be updated in-place
Remove Two ingress rules with descriptions "" and "sagemaker access" will be removed from the security group
Add Two new ingress rules with descriptions null will be added to the security group
Change The description field for some of the rules will be changed from an empty string to null
Reorder Some of the rules will be reordered
@pkutaj
pkutaj / 2023-07-17-How-to-Create-Dummy-Context-Manager-for-Python-Unit-Tests.md
Created July 17, 2023 03:55
2023-07-17-How-to-Create-Dummy-Context-Manager-for-Python-Unit-Tests.md
Code Explanation
from contextlib import nullcontext Import the nullcontext context manager from the contextlib module.
monkeypatch.setattr(schema_patcher, "handle_patching", lambda _: nullcontext()) Replace the handle_patching function with a lambda function that returns a nullcontext object.
with push_and_pop_path(MODULE_PATH): schema_patcher.patch_schema(iglu) Call the patch_schema function within a with statement that uses the push_and_pop_path context manager.
@pkutaj
pkutaj / 2023-07-14-Explaining-Current-and-Noncurrent-Versions-in-S3-Lifecycle-Policies.md
Last active July 14, 2023 10:04
2023-07-14-Explaining-Current-and-Noncurrent-Versions-in-S3-Lifecycle-Policies.md
Rule ID Status Noncurrent Version Expiration (days) Transition Storage Class Transition Days Expiration Days
foo1 Disabled 90 N/A N/A N/A
foo2 Enabled 90 STANDARD_IA 30 90