Skip to content

Instantly share code, notes, and snippets.

@joatmon08
joatmon08 / bucket_spec.rb
Last active May 2, 2019 18:41
TDD-Infra-integration-bucket
require './spec_helper'
bucket_policy = JSON.parse(File.open("../../policies/bucket.json").read)
describe s3_bucket(@bucket_name) do
it { should exist }
its(:acl_grants_count) { should eq 1 }
its('policy.policy.read') { should include bucket_policy['Statement'][0]['Sid'] }
its('policy.policy.read') { should include bucket_policy['Statement'][0]['Action'][0] }
its('policy.policy.read') { should include bucket_policy['Statement'][0]['Resource'][0] }
@joatmon08
joatmon08 / TDD-Infra-contract-test.go
Created May 1, 2019 16:57
TDD-Infra-contract-test
package test
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@joatmon08
joatmon08 / TDD-Infra-bucket-04.json
Created April 20, 2019 19:44
TDD-Infra-bucket-04
{
"Version": "2012-10-17",
"Id": "MyBucketPolicy",
"Statement": [
{
"Sid": "AllowWriteUser",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::REDACTED:user/MyBucketWriteUser"
},
@joatmon08
joatmon08 / TDD-Infra-bucket-03.json
Created April 20, 2019 19:35
TDD-Infra-bucket-03
{
"Version": "2012-10-17",
"Id": "MyBucketPolicy",
"Statement": [
{
"Sid": "AllowWriteUser",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::REDACTED:user/MyBucketWriteUser"
},
@joatmon08
joatmon08 / TDD-Infra-bucket-test-write.go
Last active April 20, 2019 19:42
TDD-Infra-bucket-test-write
package test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
const BucketPolicyFilePath = "../../policies/bucket.json"
@joatmon08
joatmon08 / TDD-Infra-bucket-02.json
Created April 20, 2019 19:18
TDD-Infra-bucket-02
{
"Version": "2012-10-17",
"Id": "MyBucketPolicy",
"Statement": [
{
"Sid": "AllowWriteUser",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::AccountID:user/test"
},
@joatmon08
joatmon08 / TDD-Infra-bucket-test-01.go
Last active May 2, 2019 19:54
TDD-Infra-bucket-01
package test
import (
"testing"
"github.com/stretchr/testify/assert"
)
const BucketPolicyFilePath = "../../policies/bucket.json"
@joatmon08
joatmon08 / hello-stateful-new-cr-restore.yml
Created October 7, 2018 16:06
Hello Stateful New CustomResource with Restore
---
apiVersion: "hello-stateful.example.com/v1alpha1"
kind: "HelloStateful"
metadata:
name: "new-hello-stateful"
spec:
replicas: 1
restoreFromExisting: true
backupSchedule: "*/5 * * * *"
@joatmon08
joatmon08 / hello-stateful-new-cr.yaml
Created October 7, 2018 15:56
Hello Stateful New CustomResource
---
apiVersion: "hello-stateful.example.com/v1alpha1"
kind: "HelloStateful"
metadata:
name: "new-hello-stateful"
spec:
replicas: 1
restoreFromExisting: false
backupSchedule: "*/5 * * * *"
@joatmon08
joatmon08 / hello-stateful-rbac.yml
Created October 7, 2018 15:41
Hello Stateful Final RBAC
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: hello-stateful-operator
rules:
- apiGroups:
- hello-stateful.example.com
resources:
- "*"