This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 4.0" | |
} | |
} | |
} | |
provider "aws" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def strip_pure(sentence: str) -> str: | |
return sentence.strip() | |
strip_impure_call_count = 0 | |
def strip_impure(sentence: str) -> str: | |
global strip_impure_call_count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
Person = namedtuple("Person", ["name", "age"]) | |
if __name__ == "__main__": | |
people = [ | |
Person("Marie Curie", 66), | |
Person("Katherine Johnson", 101), | |
Person("Ada Lovelace", 36), | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable | |
def double(n: int) -> int: | |
return 2 * n | |
def is_even(n: int) -> bool: | |
return n % 2 == 0 | |
def make_adder(n: int) -> Callable[int, int]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "snowflake_current_account" "this" {} | |
resource "snowflake_schema" "sandbox_tools" { | |
provider = snowflake.sys_admin | |
database = snowflake_database.sandbox.name | |
name = "TOOLS" | |
} | |
resource "snowflake_schema_grant" "usage_sandbox_tools" { | |
provider = snowflake.security_admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "snowflake_stage" "snowflake_s3_backup" { | |
provider = snowflake.account_admin | |
name = "SNOWFLAKE_S3_BACKUP" | |
url = "s3://${aws_s3_bucket.snowflake_backups_bucket.bucket}/" | |
database = snowflake_database.sandbox.name | |
schema = snowflake_schema.sandbox_tools.name | |
file_format = "TYPE=CSV COMPRESSION=GZIP FIELD_OPTIONALLY_ENCLOSED_BY= '\"' SKIP_HEADER=1" | |
storage_integration = snowflake_storage_integration.snowflake_s3_backup.name | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "snowflake_database_grant" "usage_sandbox_database" { | |
provider = snowflake.security_admin | |
database_name = snowflake_database.sandbox.name | |
privilege = "USAGE" | |
roles = [ | |
snowflake_role.sandbox_rw.name, | |
snowflake_role.task_admin.name # UPDATE | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let schemaTablePairResult = getSchemaTablePairResult(DATABASE); | |
while (schemaTablePairResult.next()) { | |
let schema = schemaTablePairResult.getColumnValue(1); | |
let table = schemaTablePairResult.getColumnValue(2); | |
copyToS3(DATABASE, schema, table); | |
} | |
return `Database '${DATABASE}' successfully backed up to S3.`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "snowflake_procedure" "backup_database" { | |
provider = snowflake.sys_admin | |
name = "SPROC_BACKUP_DATABASE" | |
database = snowflake_database.sandbox.name | |
schema = snowflake_schema.sandbox_tools.name | |
arguments { | |
name = "DATABASE" | |
type = "VARCHAR" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "random_id" "aws_resource_id" { | |
byte_length = 4 | |
} | |
resource "aws_s3_bucket" "snowflake_backups_bucket" { | |
bucket = "snowflake-backups-${lower(random_id.aws_resource_id.id)}" | |
acl = "private" | |
versioning { |