From 60d31b104653855412d9f5f9763530823e2674d7 Mon Sep 17 00:00:00 2001 From: Scott DeWitt Date: Wed, 3 May 2023 10:54:26 -0400 Subject: [PATCH] Added lambda support and goreleaser. --- .gitignore | 4 + .goreleaser.yaml | 72 ++++++++++ .../nr-entity-tag-sync-lambda.go | 39 ++++++ deployments/Dockerfile-lambda | 4 + deployments/cf-params.sample.json | 46 +++++++ deployments/cf-template.yaml | 127 ++++++++++++++++++ go.mod | 5 +- go.sum | 21 +++ scripts/lambda/delete.sh | 17 +++ scripts/lambda/deploy.sh | 15 +++ 10 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 .goreleaser.yaml create mode 100644 cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go create mode 100644 deployments/Dockerfile-lambda create mode 100644 deployments/cf-params.sample.json create mode 100644 deployments/cf-template.yaml create mode 100755 scripts/lambda/delete.sh create mode 100755 scripts/lambda/deploy.sh diff --git a/.gitignore b/.gitignore index d4cd5ba..7c218a7 100644 --- a/.gitignore +++ b/.gitignore @@ -120,3 +120,7 @@ dist .pnp.* config.yml + +dist/ +cf-params.json +.build.env diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..218e2a7 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,72 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + +builds: + - id: standalone + main: ./cmd/nr-entity-tag-sync/nr-entity-tag-sync.go + env: + - CGO_ENABLED=0 + goos: + - linux + #- windows + #- darwin + goarch: + - amd64 + - id: lambda + main: ./cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go + binary: nr-entity-tag-sync-lambda + env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + +dockers: + - id: lambda-image + ids: + - lambda + image_templates: + - "{{ .Env.AWS_ECR_REPO_URI }}:latest" + - "{{ .Env.AWS_ECR_REPO_URI }}:{{ .Tag }}" + dockerfile: ./deployments/Dockerfile-lambda + extra_files: + - configs/config.yml + +archives: + - format: tar.gz + builds: + - standalone + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go b/cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go new file mode 100644 index 0000000..dc3bee7 --- /dev/null +++ b/cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go @@ -0,0 +1,39 @@ +package main + +import ( + "context" + "fmt" + + _ "github.com/newrelic/nr-entity-tag-sync/internal/provider/servicenow" + + "github.com/aws/aws-lambda-go/lambda" + "github.com/newrelic/nr-entity-tag-sync/internal/sync" + "github.com/newrelic/nr-entity-tag-sync/pkg/interop" +) + +type TagSyncResult struct { + Success bool + Message error +} + +func HandleRequest(ctx context.Context) (TagSyncResult, error) { + i, err := interop.NewInteroperability() + if err != nil { + retErr := fmt.Errorf("failed to create interop: %s", err) + return TagSyncResult{false, retErr}, retErr + } + + defer i.Shutdown() + + err = sync.Sync(i) + if err != nil { + retErr := fmt.Errorf("sync failed: %s", err) + return TagSyncResult{false, retErr}, retErr + } + + return TagSyncResult{true, nil}, nil +} + +func main() { + lambda.Start(HandleRequest) +} diff --git a/deployments/Dockerfile-lambda b/deployments/Dockerfile-lambda new file mode 100644 index 0000000..5813013 --- /dev/null +++ b/deployments/Dockerfile-lambda @@ -0,0 +1,4 @@ +FROM public.ecr.aws/lambda/provided:al2 +COPY nr-entity-tag-sync-lambda /main +COPY configs/config.yml /var/task/configs/config.yml +ENTRYPOINT [ "/main" ] diff --git a/deployments/cf-params.sample.json b/deployments/cf-params.sample.json new file mode 100644 index 0000000..460e5da --- /dev/null +++ b/deployments/cf-params.sample.json @@ -0,0 +1,46 @@ +[ + { + "ParameterKey": "ImageRepoUri", + "ParameterValue": "12345.dkr.ecr.aws_region.amazonaws.com/example-repo-name" + }, + { + "ParameterKey": "ImageTag", + "ParameterValue": "1.0.0" + }, + { + "ParameterKey": "ExecRoleArn", + "ParameterValue": "arn:aws:iam::12345:role/my-execute-lambda-role" + }, + { + "ParameterKey": "FunctionName", + "ParameterValue": "NrEntityTagSync" + }, + { + "ParameterKey": "FunctionTimeout", + "ParameterValue": "120" + }, + { + "ParameterKey": "FunctionMemorySize", + "ParameterValue": "512" + }, + { + "ParameterKey": "NRLicenseKey", + "ParameterValue": "123456" + }, + { + "ParameterKey": "NRLogLevel", + "ParameterValue": "INFO" + }, + { + "ParameterKey": "UserApiKey", + "ParameterValue": "123456" + }, + { + "ParameterKey": "SnowApiUser", + "ParameterValue": "admin" + }, + { + "ParameterKey": "SnowApiPassword", + "ParameterValue": "admin" + } +] diff --git a/deployments/cf-template.yaml b/deployments/cf-template.yaml new file mode 100644 index 0000000..dade4c5 --- /dev/null +++ b/deployments/cf-template.yaml @@ -0,0 +1,127 @@ +AWSTemplateFormatVersion: '2010-09-09' +Description: Sample CloudFormation template for deploying the AWS Lambda image. + +Parameters: + # + # URI of the ECR repository. + # + ImageRepoUri: + Type: String + Description: URI of the ECR repository. + # + # ECR image tag. + # + ImageTag: + Type: String + Description: ECR image tag. + Default: latest + # + # ARN of the lambda execution role used to execute the lambda. + # + # Used during deployment. + # + ExecRoleArn: + Type: String + Description: ARN of the IAM role used for lambda execution. + AllowedPattern: 'arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+' + # + # Name of the lambda function. + # + # Used during deployment. + # + FunctionName: + Type: String + Description: Name of the lambda function. + Default: NrEntityTagSync + # + # Timeout (in seconds) for the lambda function. + # + # Used during deployment. + # + FunctionTimeout: + Type: Number + Description: Timeout (in seconds) for the lambda function. + MinValue: 1 + MaxValue: 900 + Default: 60 + # + # Memory size for the lambda function. + # + # Used during deployment. + # + FunctionMemorySize: + Type: Number + Description: Memory size for the lambda function. + MinValue: 128 + MaxValue: 10240 + Default: 256 + # + # New Relic license key for the New Relic Go APM agent. + # + NRLicenseKey: + Type: String + Description: Your New Relic license key. + AllowedPattern: '[a-zA-Z0-9\-_]*' + Default: '' + # + # Log level for the New Relic AWS lambda extension. Defaults to 'INFO'. + # + # Used at runtime by the New Relic AWS lambda extension. + # See https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/account-linking/#env-var + # + NRLogLevel: + Type: String + Description: Log level for the New Relic Lamba extension. + Default: INFO + AllowedValues: + - INFO + - DEBUG + # + # New Relic User API key used for GraphQL Nerdstorage queries and mutations. + # + UserApiKey: + Type: String + Description: The New Relic User API key to use. + AllowedPattern: '[a-zA-Z0-9._\-]*' + Default: '' + # + # Service Now API user name used by the Service Now provider. + # + SnowApiUser: + Type: String + Description: The Service Now API user. + Default: '' + # + # Service Now API password name used by the Service Now provider. + # + SnowApiPassword: + Type: String + Description: The Service Now API password. + Default: '' + +Resources: + + # + # The lambda. + # + + NrEntityTagSync: + Type: AWS::Lambda::Function + Properties: + PackageType: Image + Code: + ImageUri: !Sub ${ImageRepoUri}:${ImageTag} + Role: !Sub ${ExecRoleArn} + Description: A lambda for syncing tags between external entities and New Relic entities. + FunctionName: !Sub ${FunctionName} + Timeout: !Ref FunctionTimeout + MemorySize: !Ref FunctionMemorySize + Environment: + Variables: + # Lambda environment variables + NEW_RELIC_LICENSE_KEY: !Sub ${NRLicenseKey} + NEW_RELIC_API_KEY: !Sub ${UserApiKey} + + # Service Now provider variables + NR_CMDB_SNOW_APIUSER: !Sub ${SnowApiUser} + NR_CMDB_SNOW_APIPASSWORD: !Sub ${SnowApiPassword} diff --git a/go.mod b/go.mod index 3b80a15..389b063 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,12 @@ module github.com/newrelic/nr-entity-tag-sync go 1.20 require ( + github.com/aws/aws-lambda-go v1.40.0 + github.com/hasura/go-graphql-client v0.9.2 github.com/newrelic/go-agent/v3 v3.21.0 github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus v1.0.0 github.com/sirupsen/logrus v1.9.0 + github.com/spf13/cast v1.5.0 github.com/spf13/viper v1.15.0 ) @@ -14,13 +17,11 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hasura/go-graphql-client v0.9.2 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/spf13/afero v1.9.3 // indirect - github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.4.2 // indirect diff --git a/go.sum b/go.sum index c76141b..230e391 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/aws/aws-lambda-go v1.40.0 h1:6dKcDpXsTpapfCFF6Debng6CiV/Z3sNHekM6bwhI2J0= +github.com/aws/aws-lambda-go v1.40.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -58,7 +60,9 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -67,11 +71,17 @@ github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -136,8 +146,11 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/graph-gophers/graphql-go v1.5.0 h1:fDqblo50TEpD0LY7RXk/LFVYEVqo3+tXMNMPSVXA1yc= github.com/graph-gophers/graphql-go v1.5.0/go.mod h1:YtmJZDLbF1YYNrlNAuiO5zAStUWc3XZT07iGsVqe1Os= +github.com/graph-gophers/graphql-transport-ws v0.0.2 h1:DbmSkbIGzj8SvHei6n8Mh9eLQin8PtA8xY9eCzjRpvo= github.com/graph-gophers/graphql-transport-ws v0.0.2/go.mod h1:5BVKvFzOd2BalVIBFfnfmHjpJi/MZ5rOj8G55mXvZ8g= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -148,6 +161,7 @@ github.com/hasura/go-graphql-client v0.9.2/go.mod h1:AarJlxO1I59MPqU/TC7gQP0BMFg github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -160,14 +174,18 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/newrelic/go-agent/v3 v3.21.0 h1:KpkoW6PnSVzEDEO0W/C9LZEZZGwAb+a9g5DN8ifvt4Y= github.com/newrelic/go-agent/v3 v3.21.0/go.mod h1:rT6ZUxJc5rQbWLyCtjqQCOcfb01lKRFbc1yMQkcboWM= github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus v1.0.0 h1:i7maT5Pi3qv2xlUU/vm/C5BkG8YMLlIHfIWtMmXz7cY= @@ -208,7 +226,9 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -524,6 +544,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/scripts/lambda/delete.sh b/scripts/lambda/delete.sh new file mode 100755 index 0000000..171a38b --- /dev/null +++ b/scripts/lambda/delete.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Deleting stack..." +aws cloudformation delete-stack \ + --stack-name NrEntityTagSync-Stack \ + --output table \ + --no-cli-pager \ + --color on + +echo "Waiting for stack delete to complete..." +aws cloudformation wait stack-delete-complete \ + --stack-name NrEntityTagSync-Stack \ + --output table \ + --no-cli-pager \ + --color on + +echo "Done." diff --git a/scripts/lambda/deploy.sh b/scripts/lambda/deploy.sh new file mode 100755 index 0000000..86a3237 --- /dev/null +++ b/scripts/lambda/deploy.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +ROOT_DIR="$(dirname $(dirname ${SCRIPT_DIR}))" + +echo "Deploying stack..." +aws cloudformation deploy \ + --stack-name NrEntityTagSync-Stack \ + --template-file $ROOT_DIR/deployments/cf-template.yaml \ + --output table \ + --no-cli-pager \ + --color on \ + --parameter-overrides file://$ROOT_DIR/deployments/cf-params.json + +echo "Done."