Skip to content

hmrc/telemetry-lambda-resources

Repository files navigation

telemetry-lambda-resources

Brought to you by Telemetry Team

Table of Contents

Overview

This repository contains cookiecutter template resources for Telemetry AWS Lambda repositories. Only long-term, common and stable files should be added, e.g. scripts or configurations that, when the need to be changed, they can be changed in unison. It is worth noting that files in this template repository can be overridden in the repository using the templates. Simply add the file to a skip list defined in the pyproject.toml in the lambda repo.

[tool.cruft]
skip = [".bandit"]

Initialising a repository

If you have a new "empty" repository created by the Jenkins build job then it is possible to seed that repo with the contents of a cruft template repository. Follow the instructions in this Confluence article Using Cruft to initialise a new repository for guidance.

# Script used in article
git clone git@hmrc:hmrc/aws-lambda-telemetry-test
cd aws-lambda-telemetry-test
git checkout -b TEL-3166-add-cruft
cd ..
cruft create --overwrite-if-exists https://github.com/hmrc/telemetry-lambda-resources
cd aws-lambda-telemetry-test
git add .
git status
git commit -a -m "TEL-3166: add cruft" -m "Co-authored-by: Lee Myring <29373851+thinkstack@users.noreply.github.com>"
poetry init
# Team Telemetry <telemetry@digital.hmrc.gov.uk>
git add .
git commit -a -m "TEL-3166: add poetry" -m "Co-authored-by: Lee Myring <29373851+thinkstack@users.noreply.github.com>"

In order to publish new releases using the CI tooling provided by this template you will first need to create an initial tag.

git tag -a release/0.0.0 -m "release/0.0.0" && git push --tags

Linking an existing repository

The repository is meant to be used as a cookiecutter source inside the aws-lambda-* repos. To add the templates to the consuming repository, follow the procedure below.

# Update project
git checkout --branch TEL-3093-add-cruft
poetry update
poetry add --group dev cruft cookiecutter

For the next step, navigate to the folder above. Note: this is important as the cruft create will use the cruft_repo_name property to insert the templated files, overwriting where necessary, into the actual project folder

# This is an example to demonstrate the commands, your folders will be different
pwd # ~/source/hmrc/aws-lambda-telemetry-test
cd ..
pwd # ~/source/hmrc
cruft create --overwrite-if-exists https://github.com/hmrc/telemetry-lambda-resources
# At the `lambda_name` prompt make sure you enter `aws-lambda-telemetry-test` to target the correct project
cd -
pwd # ~/source/hmrc/aws-lambda-telemetry-test
git add .
# Link the templates repository
cruft link https://github.com/hmrc/telemetry-lambda-resources # Carefully enter the properties into the prompts

# Run update (this doesn't patch up local files with the contents of the templates repository)
cruft update

# Run a diff and apply those changes (this does patch up local files)
cruft diff | git apply

Updating the repository

Follow the instructions in this Confluence article Using Cruft to update an existing repository for guidance.

cruft check
cruft diff
cruft update --skip-apply-ask

# If the update does not work - an update can be forced
cruft diff | git apply

References

License

This code is open source software licensed under the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published