Skip to content

Commit

Permalink
closer to sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
loganpowell committed Nov 4, 2023
1 parent 95698d7 commit 32b559e
Show file tree
Hide file tree
Showing 6 changed files with 786 additions and 627 deletions.
70 changes: 54 additions & 16 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 29 additions & 11 deletions examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { namespace } from '../src/config'
import { dockerize } from '../src/modules/docker'
import { ecr_repository } from '../src/modules/ecr'
import { setInUnsafe } from '@thi.ng/paths'
import fs from 'fs'

const test = {}
const proof = [
Expand All @@ -16,18 +17,18 @@ const proof = [
},
]

setInUnsafe(test, ['provider'], proof) //?
//setInUnsafe(test, ['provider'], proof) //

const tags = { Moms: 'Spaghetti' }
const apex = 'chopshop-test.net'
const subdomain = 'test1'
const name = 'throwaway-test-123'

// ======= DOMAIN =======

const route53zone = ({ apex }) => ({
zone: zone({ apex }),
})

const [Zone, out_zone] = modulate({ domain: route53zone })({ apex })
const zone_id = out_zone?.zone?.data?.route53_zone?.zone_id //

Expand All @@ -42,14 +43,18 @@ const topic_arn = out_topic?.sns?.resource?.sns_topic?.arn //

// ======= DOCKER =======

const repo_name = `${name.split('.').reverse().join('/')}/${subdomain}`
const repo_name = `${name.split('.').reverse().join('/')}/${subdomain}` //?
const repoMod = modulate({ repo: ecr_repository })
const [Repo, out_repo] = repoMod({
name: repo_name,
tags,
})

const dockerMod = modulate({ docker: dockerize })
JSON.stringify(Repo, null, 4) //?
JSON.stringify(out_repo, null, 4) //?

const dockerMod = modulate({ docker: dockerize }, ['docker_image', 'docker_registry_image'])

const [Docker, out_docker] = dockerMod({
name,
src_path: '${path.root}/src/docker',
Expand All @@ -61,14 +66,15 @@ const [Docker, out_docker] = dockerMod({
repo: repo_name,
},
})
JSON.stringify(Docker, null, 4) //?

const image_uri = out_docker?.registry_img?.resource?.docker_registry_image?.name
//JSON.stringify(Docker, null, 4) //?
//JSON.stringify(out_docker, null, 4) //?

const image_uri = out_docker?.registry_img?.resource?.docker_registry_image?.name //?

// ======= LAMBDA =======

const lambdaMod = modulate({ ms1: lambda })

const [Lambda, out_lambda] = lambdaMod({
name,
//file_path: '${path.root}/lambdas/template/zipped/handler.py.zip',
Expand All @@ -95,9 +101,9 @@ const [Lambda, out_lambda] = lambdaMod({
})

JSON.stringify(Lambda, null, 4) //?
JSON.stringify(out_lambda, null, 4) //?

const functionInvokeArn = out_lambda?.lambda?.resource?.lambda_function?.invoke_arn //?

const functionInvokeArn = out_lambda?.lambda?.resource?.lambda_function?.invoke_arn //
const functionName = out_lambda?.lambda?.resource?.lambda_function?.function_name

// ======= API =======
Expand Down Expand Up @@ -153,11 +159,21 @@ const terraform = {
},
}

const micro = { Zone, Topic, Repo, Docker, Lambda, Api, provider, terraform }
const micro = {
Zone,
Topic,
Repo,
Docker,
Lambda,
Api,
provider,
terraform,
}

const compiled = namespace({ micro })
const json = JSON.stringify(compiled, null, 2) //?

console.log(JSON.stringify(compiled, null, 4)) //?
fs.writeFileSync('micro.tf.json', json)

// ~~~888~~~ ,88~-_ 888~-_ ,88~-_
// 888 d888 \ 888 \ d888 \
Expand All @@ -170,6 +186,8 @@ console.log(JSON.stringify(compiled, null, 4)) //?
// - JIT lambda compilation for:
// - zipped lambdas
// - image lambdas
// - README: add note about naming files the same as your modules, so they can
// be identified from payload

/**
* Outline of microservice module:
Expand Down
Loading

0 comments on commit 32b559e

Please sign in to comment.