Skip to content

Instantly share code, notes, and snippets.

@rkhozinov
rkhozinov / aws_eks_iam_terraform_v0.12.tf
Created January 5, 2020 17:50
AWS EKS IAM Terraform v0.12
variable "eks_cluster_name" {}
provider "aws" {}
data "aws_eks_cluster" "this" {
name = var.eks_cluster_name
}
# https://www.terraform.io/docs/providers/aws/r/iam_openid_connect_provider.html
resource "aws_iam_openid_connect_provider" "this" {
@rkhozinov
rkhozinov / aws_eks_iam_terraform_v0.11.tf
Last active January 5, 2020 17:49
AWS EKS IAM Terraform v0.11
variable "eks_cluster_name" {}
provider "aws" {}
data "aws_eks_cluster" "this" {
name = "${var.eks_cluster_name}"
}
# https://www.terraform.io/docs/providers/aws/r/iam_openid_connect_provider.html
resource "aws_iam_openid_connect_provider" "this" {
@rkhozinov
rkhozinov / iter_test.rs
Created December 24, 2019 13:58 — forked from philipjkim/iter_test.rs
Rust: Difference between iter(), into_iter(), and iter_mut()
#[test]
fn iter_demo() {
let v1 = vec![1, 2, 3];
let mut v1_iter = v1.iter();
// iter() returns an iterator of slices.
assert_eq!(v1_iter.next(), Some(&1));
assert_eq!(v1_iter.next(), Some(&2));
assert_eq!(v1_iter.next(), Some(&3));
assert_eq!(v1_iter.next(), None);
@rkhozinov
rkhozinov / convert_bucket_policies_from_tf_state_to_data_source.py
Last active September 17, 2019 12:08
Allows to parse s3 bucket policies from a terraform state and convert them to aws_iam_policy_document data source
from json import load, loads
from jinja2 import Template
template = """data "aws_iam_policy_document" "{{ bucket }}" {
{%- for st in statement %}
statement {
sid = "{{ st.Sid }}"
effect = "{{ st.Effect }}"
actions = [
@rkhozinov
rkhozinov / get_s3_buckets_size.sh
Last active September 17, 2019 11:45
Prepare a csv file for s3 buckets size list
#!/usr/bin/env bash
buckets=($(aws --region us-east-1 s3api list-buckets --output text --query 'Buckets[].Name'))
echo "bucket name,size(Bytes)" > buckets_storage.csv
for bucket in "${buckets[@]}"; do
size=$(aws cloudwatch get-metric-statistics \
--region us-east-1 \
--metric-name BucketSizeBytes \
@rkhozinov
rkhozinov / move_git_branches.sh
Last active September 13, 2019 11:10
The script allows to move branches to the $prefix/
#!/usr/bin/env bash
# put the list of branches here
branches=(
branch1
branch1
)
prefix=rkh
author=Ruslan
@rkhozinov
rkhozinov / bumpme
Last active September 12, 2019 22:52
concourse-stuff
Thu Sep 12 22:24:56 UTC 2019
@rkhozinov
rkhozinov / ps
Created December 22, 2017 21:44
using System;
using System.Collections.Generic;
namespace student
{
public class Student : IComparer<Student>, IComparable<Student>
{
private string name;
private string lastname;
private short year;
public void RemoveStudent(string name, string lastname)
{
string _name = Student.FirstCapital(name);
string _lastname = Student.FirstCapital(lastname);
int index = 0;
foreach (Student student in Items)
{
@rkhozinov
rkhozinov / cs
Created December 14, 2017 11:27
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using student;
namespace program
{
class Program