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-name
terraform init
Ensure you have the following environment variables set up for the Terraform run:
ARM_CLIENT_ID
ARM_CLIENT_SECRET
ARM_SUBSCRIPTION_ID
ARM_TENANT_ID
TF_VAR_member_id
TF_VAR_member_pin
TF_VAR_admin_password
TF_VAR_mailchimp_api_key
You can set these in your shell or add them to your GitHub Secrets for automated workflows.
terraform apply -auto-approve
Go to your GitHub repository, then navigate to Settings > Secrets and variables > Actions and add the following secrets:
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_SUBSCRIPTION_ID
AZURE_TENANT_ID
MEMBER_ID
MEMBER_PIN
ADMIN_PASSWORD
MAILCHIMP_API_KEY
AZURE_FUNCTIONAPP_PUBLISH_PROFILE
Ensure that the .github/workflows
directory contains the following workflow files:
deploy-terraform.yml
deploy-function.yml
pip install -r requirements.txt
You can run the script locally for testing purposes:
python sync_with_ig.py
Every 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!