This project contains a Python script that synchronizes contacts from a golf club's CRM with an audience in Mailchimp. The script is designed to run as an Azure Function and uses Terraform for infrastructure management. The setup includes secure handling of sensitive information using Azure Key Vault and GitHub Secrets.
Before you begin, ensure you have the following prerequisites:
- Azure CLI
- Terraform
- GitHub CLI or Git configured for your repository
- An Azure account with appropriate permissions
- Python 3.8 or later
git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-nameterraform initEnsure you have the following environment variables set up for the Terraform run:
ARM_CLIENT_IDARM_CLIENT_SECRETARM_SUBSCRIPTION_IDARM_TENANT_IDTF_VAR_member_idTF_VAR_member_pinTF_VAR_admin_passwordTF_VAR_mailchimp_api_key
You can set these in your shell or add them to your GitHub Secrets for automated workflows.
terraform apply -auto-approveGo to your GitHub repository, then navigate to Settings > Secrets and variables > Actions and add the following secrets:
AZURE_CLIENT_IDAZURE_CLIENT_SECRETAZURE_SUBSCRIPTION_IDAZURE_TENANT_IDMEMBER_IDMEMBER_PINADMIN_PASSWORDMAILCHIMP_API_KEYAZURE_FUNCTIONAPP_PUBLISH_PROFILE
Ensure that the .github/workflows directory contains the following workflow files:
deploy-terraform.ymldeploy-function.yml
pip install -r requirements.txtYou can run the script locally for testing purposes:
python sync_with_ig.pyEvery push to the main branch will trigger GitHub Actions workflows to deploy the Terraform infrastructure and update the Azure Function.
You can manually trigger the function or deploy updates through the Azure Portal or using the Azure CLI.
.
├── .github
│ └── workflows
│ ├── deploy-terraform.yml
│ └── deploy-function.yml
├── main.tf
├── requirements.txt
├── sync_with_ig.py
├── variables.tf
└── terraform.tfvars (do not commit real values)
- Secrets Management: Secrets are managed using Azure Key Vault and GitHub Secrets to ensure sensitive information is not exposed in the codebase.
- Terraform State: Use a remote backend to securely store Terraform state files.
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions, feel free to contact the project maintainers.
Happy syncing!