Skip to content

Commit

Permalink
stubs out packaging functions
Browse files Browse the repository at this point in the history
  • Loading branch information
loganpowell committed Oct 31, 2023
1 parent 56240c6 commit 78e058e
Show file tree
Hide file tree
Showing 72 changed files with 4,854 additions and 545 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
id: build_image_step
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: your-repo-name
ECR_REPOSITORY: micro-test
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker build \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "::set-output name=image_tag::$IMAGE_TAG"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.env
.venv
.vscode
node_modules
state.tf.json
throwaway
Expand Down
75 changes: 59 additions & 16 deletions .terraform.lock.hcl

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

21 changes: 16 additions & 5 deletions examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { modulate, config, lambda, api, topic, zone } from '../src/index'
import type { Provider, Terraform } from '../src/types'
import { modulate, config, lambda, api, topic, zone, Provider, Terraform } from '../src/index'

const apex = 'chopshop-test.net'
const name = 'throwaway-test-123'
Expand All @@ -24,6 +23,7 @@ const topic_arn = out_topic?.sns?.resource?.sns_topic?.arn //
// ======= LAMBDA =======

const lambdaMod = modulate({ ms1: lambda })

const [mod_lambda, out_lambda] = lambdaMod({
name,
file_path: '${path.root}/lambdas/template/zipped/handler.py.zip',
Expand All @@ -47,6 +47,7 @@ const [mod_lambda, out_lambda] = lambdaMod({
},
tags,
})

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

Expand All @@ -65,7 +66,7 @@ const [mod_api, out_api] = modulate({ api })({
},
tags,
})
//JSON.stringify(out_api, null, 4)
//JSON.stringify(out_api, null, 4)

// ======= COMPILE =======

Expand All @@ -80,7 +81,17 @@ const terraform: Terraform = {
required_providers: {
aws: {
source: 'hashicorp/aws',
version: '5.20.0',
version: '>= 5.20',
},
// for docker
docker: {
source: 'kreuzwerker/docker',
version: '>= 3.0',
},
// for null resources
null: {
source: 'hashicorp/null',
version: '>= 2.0',
},
},
}
Expand All @@ -89,7 +100,7 @@ const compile = config(provider, terraform, 'main.tf.json')
const micro = [mod_zone, mod_topic, mod_lambda, mod_api]
const compiled = compile(...micro)

JSON.stringify(compiled, null, 4) //?
console.log(JSON.stringify(compiled, null, 4)) //?

// ~~~888~~~ ,88~-_ 888~-_ ,88~-_
// 888 d888 \ 888 \ d888 \
Expand Down
4 changes: 2 additions & 2 deletions lib/src/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Provider, Terraform, NestedObject } from './constants';
import { Provider, Terraform, NestedObject } from './types';
/**
* flattens modules into a single object, with unique keys created by
* joining nested key identifiers until the function reaches a pivot point
* (resource or data) and then prepending the module name to the key ("_").
*/
export declare const flattenPreservingPaths: (obj: object, provider?: string, path?: string[], acc?: NestedObject, refs?: boolean) => object;
export declare const flattenPreservingPaths: (obj: object, provider?: string, path?: any[], acc?: NestedObject, refs?: boolean) => object;
type FnParams<T extends (...args: any[]) => any> = T extends (...args: infer P) => any ? P : never;
type FnReturn<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : never;
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/src/config.d.ts.map

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

37 changes: 28 additions & 9 deletions lib/src/config.js

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

Loading

0 comments on commit 78e058e

Please sign in to comment.