Skip to content

WIP: add(integrations): salesforce #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- github-issue
- cloudflare
- supabase
- salesforce
indent-runtime: [aws-lambda]
steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: deploy.indent-salesforce-webhook

on:
push:
branches:
- main
pull_request:

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }} # if you have/need it
aws-region: ${{ secrets.AWS_REGION }}

- name: Terraform Format
id: fmt
run: terraform fmt -check -diff

- name: Build Webhook (terraform-aws-salesforce-webhook)
run: cd terraform-aws-salesforce-webhook && npm run deploy:prepare && npm install && npm run build

- name: Terraform Init
id: init
run: terraform init

- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: terraform plan -input=false -no-color
continue-on-error: true
env:
TF_VAR_indent_webhook_secret: ${{ secrets.SALESFORCE_WEBHOOK_SECRET }}
TF_VAR_indent_pull_webhook_secret: ${{ secrets.SALESFORCE_PULL_WEBHOOK_SECRET }}
TF_VAR_okta_domain: ${{ secrets.SALESFORCE_ACCOUNT}}
TF_VAR_okta_token: ${{ secrets.SALESFORCE_ACCESS_TOKEN }}

- uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`${process.env.PLAN}\`\`\`
</details>
*Actor: @${{ github.actor }}, Event: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1

- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -input=false -auto-approve
env:
TF_VAR_indent_webhook_secret: ${{ secrets.SALESFORCE_WEBHOOK_SECRET }}
TF_VAR_indent_pull_webhook_secret: ${{ secrets.SALESFORCE_PULL_WEBHOOK_SECRET }}
TF_VAR_salesforce_instance_url: ${{ secrets.SALESFORCE_INSTANCE_URL }}
TF_VAR_salesforce_access_token: ${{ secrets.SALESFORCE_ACCESS_TOKEN }}
12 changes: 12 additions & 0 deletions examples/aws-lambda-salesforce-webhook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
data
dist
lib
.env
node_modules
*.tfstate
.terraform*
*.tfstate.*
terraform/config/*.tfvars
!terraform/config/example.tfvars
yarn.lock
package-lock.json
1 change: 1 addition & 0 deletions examples/aws-lambda-salesforce-webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Indent + Salesforce
24 changes: 24 additions & 0 deletions examples/aws-lambda-salesforce-webhook/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# terraform {
# backend "s3" {
# encrypt = true
# bucket = ""
# region = "us-west-2"
# key = "indent/terraform.tfstate"
# }
# }

module "salesforce-pull-webhook" {
source = "./terraform-aws-salesforce-webhook/terraform"

indent_webhook_secret = var.salesforce_pull_webhook_secret
salesforce_instance_url = var.salesforce_instance_url
salesforce_access_token = var.salesforce_access_token
}

module "salesforce-change-webhook" {
source = "./terraform-aws-salesforce-webhook/terraform"

indent_webhook_secret = var.salesforce_webhook_secret
salesforce_instance_url = var.salesforce_instance_url
salesforce_access_token = var.salesforce_access_token
}
9 changes: 9 additions & 0 deletions examples/aws-lambda-salesforce-webhook/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "pull_api_base_url" {
value = module.salesforce-pull-webhook.api_base_url
description = "The URL of the deployed Lambda"
}

output "api_base_url" {
value = module.salesforce-change-webhook.api_base_url
description = "The URL of the deployed Lambda"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data
dist
lib
.env
node_modules
*.tfstate
.terraform
*.tfstate.*
terraform/config/*.tfvars
!terraform/config/example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@indent/terraform-aws-salesforce-webhook",
"version": "0.0.0",
"description": "A Node.js starter for Terraform on AWS with Indent and Okta.",
"main": "index.js",
"private": true,
"scripts": {
"build": "tsc",
"clean:dist": "rm -rf dist",
"clean:modules": "rm -rf node_modules",
"clean:tf": "rm -rf terraform/.terraform && rm -rf terraform/terraform.tfstate*",
"clean:all": "npm run clean:dist; npm run clean:tf; npm run clean:modules",
"create:all": "npm run deploy:init; npm run deploy:prepare; npm run deploy:all",
"deploy:init": "cd terraform; terraform init",
"deploy:prepare": "npm install --production && ./scripts/build-layers.sh",
"deploy:all": "npm run build && npm run tf:apply -auto-approve",
"destroy:all": "npm run tf:destroy -auto-approve",
"tf:plan": "cd terraform && terraform plan -var-file ./config/terraform.tfvars",
"tf:apply": "cd terraform && terraform apply -compact-warnings -var-file ./config/terraform.tfvars",
"tf:destroy": "cd terraform && terraform destroy -auto-approve -var-file ./config/terraform.tfvars"
},
"author": "Indent Inc <open@indent.com>",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/indentapis/integrations.git"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.39",
"@types/node": "^13.9.8",
"@types/node-fetch": "^2.5.5",
"typescript": "^3.8.3"
},
"dependencies": {
"@indent/runtime-aws-lambda": "canary",
"@indent/webhook": "latest",
"@indent/types": "latest",
"ts-node": "^8.5.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Terraform AWS + Salesforce Webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -x
set -e

ROOT_DIR="$(pwd)"

OUTPUT_DIR="$(pwd)/dist"

LAYER_DIR=$OUTPUT_DIR/layers/nodejs

mkdir -p $LAYER_DIR

cp -LR node_modules $LAYER_DIR

cd $OUTPUT_DIR/layers

zip -q -r layers.zip nodejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getLambdaHandler } from '@indent/runtime-aws'
import { SalesforceIntegration } from './integration'

export const handle = getLambdaHandler({
integrations: [new SalesforceIntegration()],
})
Loading