Public github actions workflows that are reusable within StrongMind.
graph LR
Code owners can be found in CODEOWNERS file
-
Check for Protected Resources
- If There Are Protected Resources:
- Either manually delete the protected resources via the AWS Management Console or follow the manual steps from the other method, skipping this method.
- You need to manually delete a resource in AWS if pulumi asks you to unprotect a resource.
- If There Are Protected Resources:
-
Clone the Repository
- Clone the repository for the infrastructure you want to delete.
-
Locate the Deployment Workflow
- Go to the
.github/workflowsfolder and find the deployment file for the environment you want to delete. - For example, if you are deleting production infrastructure, look for
deploy-prod.yml.
- Go to the
-
Modify the GitHub Action Workflow
- Open the deployment file (
deploy-prod.ymlor similar). - Locate the job that references:
uses: strongmind/public-reusable-workflows/.github/workflows/aws-deploy.yml@main
- Find or create the
withsection in that job. - Add 'pulumi-command: down' environment variable to the
withsection:with: pulumi-command: down
- Open the deployment file (
-
Push Changes and Merge
- Push the changes to a new branch.
- Create a pull request (PR) and merge it into the main branch.
-
Trigger the GitHub Action
- If the GitHub Action doesn't automatically start after merging the PR, manually trigger it:
- Go to the GitHub Actions tab in the repository.
- Find and run the
build.ymlworkflow from the GitHub Actions web UI.
- This should bring down the infrastructure as intended.
- NOTE: You will need to run the
build.ymlworkflow everytime pulumi asks you to unprotect/delete something.- This needs to happen so that the pulumi state file is refreshed.
- If the GitHub Action doesn't automatically start after merging the PR, manually trigger it:
-
Clone the Repository
- Clone the repository for the infrastructure you want to delete.
-
Set Up Your AWS Credentials
- Ensure your
~/.aws/credentialsfile has a[default]profile linked to the AWS account where the infrastructure resides. - For example, if the infrastructure is in the StrongMind AWS account, the
[default]profile should have access to that account.
- Ensure your
-
Set Cloudflare API Token (If Needed)
- If a Cloudflare API token is required for the infrastructure, export it as an environment variable:
export CLOUDFLARE_API_TOKEN="<cloudflare_api_token_from_bitwarden>"
- If a Cloudflare API token is required for the infrastructure, export it as an environment variable:
-
Set Up Pulumi
- Retrieve the Pulumi config passphrase from Bitwarden:
- Secret Name: "pulumi state pass Devops (and tesla)"
- Export the Pulumi passphrase:
export PULUMI_CONFIG_PASSPHRASE="<pulumi_config_passphrase_from_bitwarden>"
- Retrieve the Pulumi config passphrase from Bitwarden:
-
Login to Pulumi
- Log in to the Pulumi state file:
pulumi login s3://pulumi-state-sm/{Repository_name} - Example:
pulumi login s3://pulumi-state-sm/Helpers
- Log in to the Pulumi state file:
-
Navigate to the Infrastructure Directory
- Change to the infrastructure directory:
cd infrastructure
- Change to the infrastructure directory:
-
Create and Activate a Virtual Environment
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate - Install the required dependencies:
python3 -m pip install -r requirements.txt
- Create a virtual environment:
-
Select the Stack
- Choose the stack you want to bring down:
pulumi stack select prod
- Replace
prodwith the name of the stack you wish to delete.
- Choose the stack you want to bring down:
-
Bring Down the Infrastructure
- Run the following command to destroy the infrastructure:
pulumi down
- Dealing with Protected Resources:
- If Protected by Pulumi:
- Pulumi will provide instructions to unprotect the resource.
- Run
pulumi downagain after unprotecting the resource. - If the issue persists, follow the steps in the "If Protected by AWS" section.
- Note: If there are multiple protected resources, you will need to unprotect them individually.
- If Protected by AWS:
- Disable protection directly in the AWS Management Console.
- After doing so, run:
pulumi refresh
- Then, run
pulumi downagain to complete the teardown.
- If Protected by Pulumi:
- Run the following command to destroy the infrastructure:
You can chat with Pulumi King, an AI assistant designed to help with StrongMind infrastructure. Palumi King provides guidance on:
- AWS services and best practices
- Infrastructure as Code using Pulumi
- CI/CD workflows and automation
- Troubleshooting deployment issues
- Security and scaling strategies
To regenerate the AI-generated documentation, follow these steps:
- Use Cursor to Run the Following Prompt:
- create a file called notes.md
- go through the files in the and folders and update the notes.md with:
<node_md_content>
* mermaid diagram of the infrastructure
* list of services used
* Description of the services used and interactions with one another
</note_md_content>
- update the notes.md after each file
- go back to previous files if necessary to get a better understanding of the infrastructure
- Run This Prompt Three Times Using the Following Contexts:
- Deployment Folder
- Docs Folder
- Docs and Deployment folder
- Generated Files:
- The three generated files will serve as references for the AI assistant to understand and provide insights into the infrastructure.
By following this process, you ensure that the AI assistant stays updated with the latest infrastructure documentation.