### Run Spacelift Installer Source: https://docs.spacelift.io/self-hosted/v2.1.0/product/administration/install This command runs the Spacelift installer, using an optional configuration file. The installer sets up the necessary infrastructure. The `-c` flag allows you to specify the path to your configuration file; if omitted, it defaults to `config.json`. The example shows the initial confirmation prompt. ```bash ./install.sh [-c ""] ``` -------------------------------- ### Ansible Playbook Execution Source: https://docs.spacelift.io/self-hosted/v3.5.0/vendors/ansible/getting-started Specifies the Ansible playbook file to be executed by Spacelift. Ensure this file exists in the configured repository. ```text playbook.yml ``` -------------------------------- ### Run Spacelift Installer Source: https://docs.spacelift.io/self-hosted/latest/installing-spacelift/cloudformation/disaster-recovery This command executes the Spacelift installer script. It takes a configuration file (config.json) as input, which should include the necessary settings for the installation, particularly those related to disaster recovery. This step is crucial for completing the DR setup after configuring S3 replication. ```shell ./install.sh -c config.json ``` -------------------------------- ### Kubernetes Deployment YAML Source: https://docs.spacelift.io/self-hosted/latest/vendors/kubernetes/getting-started This YAML defines a basic Kubernetes Deployment for an Nginx application. It specifies the image to use (nginx:1.14.2), the number of replicas (2), and the container port (80). This configuration is used to create a stateless application deployment. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 2 # tells deployment to run 2 pods matching the template template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 ``` -------------------------------- ### Configure DNS Zone Entries Source: https://docs.spacelift.io/self-hosted/latest/installing-spacelift/reference-architecture/guides/deploying-to-eks Provides examples of CNAME records to be added to your DNS zone. These records point to the Spacelift server ingress and the MQTT broker, enabling access to your Spacelift installation. ```dns # This one is the main address of your Spacelift installation. # It should be a CNAME to the server-v4 ingress (see above). ${TF_VAR_server_domain} 300 IN CNAME ..elb.amazonaws.com # This one is the address of your MQTT endpoint. # It should be a CNAME to the external IP of the spacelift-mqtt service (see above). ${TF_VAR_mqtt_broker_domain} 300 IN CNAME .elb..amazonaws.com ``` -------------------------------- ### Spacelift Runner Configuration Source: https://docs.spacelift.io/self-hosted/v3.5.0/vendors/ansible/getting-started Configuration for the Spacelift runner image and Ansible settings. This defines the container environment for running Ansible playbooks. ```yaml runner_image: public.ecr.aws/spacelift/runner-ansible-aws:latest environment: ANSIBLE_CONFIG: .ansible.cfg ANSIBLE_PRIVATE_KEY_FILE: /tmp/spacelift_key.pem ``` -------------------------------- ### Create Teleport Machine ID Bot Source: https://docs.spacelift.io/self-hosted/v3.2.0/integrations/teleport This command creates a Teleport Machine ID bot named 'example' and assigns it the 'terraform-provider' role. This bot will be used by Spacelift to authenticate. ```bash tctl bots add example --roles=terraform-provider --token=example-bot # Expected output: # bot "example" has been created ``` -------------------------------- ### Create a Teleport Machine ID Bot Source: https://docs.spacelift.io/integrations/teleport This command creates a Machine ID bot named 'example'. It assigns the 'terraform-provider' role to the bot and uses the 'example-bot' token for authentication. This bot will be used by Spacelift to act as an authenticated user. ```bash tctl bots add example --roles=terraform-provider --token=example-bot ``` -------------------------------- ### Create Nginx Deployment with Kubernetes YAML Source: https://docs.spacelift.io/self-hosted/v2.0.0/vendors/kubernetes/getting-started YAML configuration file for deploying Nginx with 2 replicas on Kubernetes. This deployment manifest specifies the container image (nginx:1.14.2), port configuration (80), and replica count. Save this as deployment.yaml in your repository. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 ``` -------------------------------- ### Initialization Policy - Rego Example Source: https://docs.spacelift.io/self-hosted/v3.0.0/concepts/policy/run-initialization-policy This Rego code defines a simple initialization policy that denies all runs. It uses a single 'deny' rule with a string message, which will fail the run before it starts. This policy can protect a stack from unwanted changes or enforce organizational rules. ```rego package spacelift deny["you shall not pass"] { true } ``` -------------------------------- ### Configure Spacelift Stack for Pulumi Source: https://docs.spacelift.io/self-hosted/v2.0.0/vendors/pulumi/javascript Configuration details for a Spacelift stack using Pulumi. This includes setting the project root, installing dependencies, specifying the runner image, and configuring the state backend and stack name. ```bash project_root: aws-js-webserver before_init: - npm install runner_image: public.ecr.aws/spacelift/runner-pulumi-javascript:latest pulumi_version_tag: v2.15.4 state_backend: s3://pulumi-state-bucket stack_name: my-javascript-pulumi-spacelift-stack ``` -------------------------------- ### Authenticate and list Spacelift stacks with spacectl Source: https://docs.spacelift.io/self-hosted/latest/concepts/spacectl Provides a quick start guide for authenticating with Spacelift using `spacectl profile login` and then listing available stacks. It shows an interactive login process and the output of the `spacectl stack list` command. ```bash > spacectl profile login my-account Enter Spacelift endpoint (eg. https://unicorn.app.spacelift.io/): http://my-account.app.spacelift.tf Select authentication flow: 1) for API key, 2) for GitHub access token, 3) for login with a web browser Option: 3 > spacectl stack list Name | Commit | Author | State | Worker Pool | Locked By stack-1 | 1aa0ef62 | Adam Connelly | NONE | | stack-2 | 1aa0ef62 | Adam Connelly | DISCARDED | | ``` -------------------------------- ### Configure Spacelift Stack for Pulumi Javascript Source: https://docs.spacelift.io/self-hosted/v2.1.0/vendors/pulumi/javascript Configuration details for a Spacelift stack using Pulumi with Javascript. This includes setting the project root to the specific subdirectory, defining the npm install script, specifying the runner image, and optionally pinning a Pulumi version. ```text Project root: `aws-js-webserver` Before init script: `npm install` Runner image: `public.ecr.aws/spacelift/runner-pulumi-javascript:latest` Pulumi version tag: `v2.15.4` (example) ``` -------------------------------- ### Ansible Inventory Configuration Source: https://docs.spacelift.io/self-hosted/v3.5.0/vendors/ansible/getting-started Example of an AWS EC2 inventory file used by Ansible to discover hosts. Users can modify filters to match their specific EC2 instances. ```yaml plugin: aws_ec2 regions: - us-east-1 filters: tag: Environment: production compose: ansible_host: public_ip_address ``` -------------------------------- ### Basic Spacelift Blueprint YAML Configuration Source: https://docs.spacelift.io/concepts/blueprint This YAML configuration defines a basic Spacelift Blueprint. It includes input variables, stack settings like name and VCS configuration, and vendor settings for Terraform. This serves as a minimal example to get started with creating blueprints. ```yaml inputs: - id: stack_name name: Stack name stack: name: "${{ inputs.stack_name }}" space: root vcs: branch: main repository: my-repository provider: GITHUB vendor: terraform: manage_state: true version: "1.3.0" ``` -------------------------------- ### Usage of setup-spacectl GitHub Action Source: https://docs.spacelift.io/concepts/spacectl Demonstrates how to use the `setup-spacectl` GitHub Action to install `spacectl` in a GitHub Actions workflow and then deploy infrastructure. Requires setting Spacelift API credentials as environment variables. ```yaml steps: - name: Install spacectl uses: spacelift-io/setup-spacectl@main - name: Deploy infrastructure env: SPACELIFT_API_KEY_ENDPOINT: https://mycorp.app.spacelift.io SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }} SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }} run: spacectl stack deploy --id my-infra-stack ``` -------------------------------- ### Installer Confirmation Prompt Source: https://docs.spacelift.io/self-hosted/v2.1.0/product/administration/install This is an example of the confirmation prompt displayed by the installer, asking for explicit permission to proceed with the installation process. It's crucial to verify the AWS account ID before confirming. Entering 'yes' is required to continue. ```text ./install.sh [2023-01-24T12:17:52+0000] INFO: installing version v0.0.6 of Spacelift into AWS account 123456789012 Are you sure you want to continue? Only 'yes' will be accepted: yes ``` -------------------------------- ### Apply OpenTofu Configuration and View Output Source: https://docs.spacelift.io/self-hosted/v3.3.0/installing-spacelift/reference-architecture/guides/deploying-to-ecs This demonstrates how to apply the OpenTofu configuration and view the output. The output contains the DNS records required for ACM certificate validation. The user must then manually create these records in their DNS zone. Replace `spacelift.example.com` with your server domain. ```Bash $ TF_VAR_server_domain=spacelift.example.com tofu apply # [...] Outputs: certificate-verification-records = <` with the actual version number. ```bash tar -zxf self-hosted-.tar.gz cd self-hosted- ``` -------------------------------- ### Spacelift Workflow Hooks Example (Bash) Source: https://docs.spacelift.io/self-hosted/v3.0.0/concepts/stack/stack-settings Demonstrates how to use 'before' and 'after' hooks in Spacelift workflows. Commands executed in 'before' hooks run prior to the phase, and 'after' hooks run after. The example shows listing processes before and after a phase, and then listing Terraform's `.terraform` directory after. ```bash echo "ps aux" terraform plan echo "ls -la .terraform" ``` -------------------------------- ### Source Environment Variables for Spacelift Installation Source: https://docs.spacelift.io/self-hosted/latest/installing-spacelift/reference-architecture/guides/deploying-to-eks This command sources environment variables required for the Spacelift installation process. It utilizes the 'tofu output -raw shell' command to retrieve and export these variables, which are essential for subsequent steps in the guide. Ensure you keep the same shell open throughout the installation. ```bash $(tofu output -raw shell) ``` -------------------------------- ### Example AWS S3 Website URL Fetch Source: https://docs.spacelift.io/self-hosted/latest/vendors/pulumi/golang Demonstrates how to fetch the content of a deployed S3 static website using `curl`. This verifies the website is accessible via its S3 website endpoint. ```bash ~> curl s3-website-bucket-b47a23a.s3-website.eu-central-1.amazonaws.com Hello Amazon S3

Hello, world!

Made with ❤️ with Pulumi

``` -------------------------------- ### Start Services in Secondary Region (Shell) Source: https://docs.spacelift.io/self-hosted/latest/installing-spacelift/cloudformation/disaster-recovery Starts services in the secondary region for disaster recovery failover. It requires a configuration file specific to the disaster recovery setup. Ensure the database is ready before execution. ```shell ./start-stop-services.sh -e true -c config.dr.json ``` -------------------------------- ### Spacelift Workflow Hooks Example (Bash) Source: https://docs.spacelift.io/self-hosted/v2.2.0/concepts/stack/stack-settings This example demonstrates how to use Spacelift workflow hooks to execute commands before and after a specific phase. It includes 'before' hooks for setting up and 'after' hooks for verification. Commands are chained using '&&' to ensure proper execution flow. ```bash # Example showing 'before' and 'after' hooks for a phase # The 'before' hooks run before the main phase command # The 'after' hooks run after the main phase command, only if it succeeds # Commands like 'ps aux' and 'ls' are executed as 'before' hooks # Commands like 'ls -la .terraform' are executed as 'after' hooks ``` -------------------------------- ### Example Certificate (Base64 Encoded) Source: https://docs.spacelift.io/self-hosted/v2.2.0/product/administration/advanced-installations This is a base64 encoded string representing a sample certificate. It is provided as an example and should not be used in production environments without proper validation and replacement. ```base64 LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZzVENDQTVtZ0F3SUJBZ0lVREQvNFZCZkx4NUsvdEFZK1Nja0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QYUZqVi8rVXhheDJtQWxBUmsKZnFZeVdvcXZaSDkwY3pwdkZHMWpVbzZQNE5weXhaUzhsYXlKd0QyNHFYK0VPTjQzV1lBcExzbC9qRTJBL0ptUQpNZGdXTmhPeTRIUDhVOCthQU5yMEV2N2dXV05pNlZjUjhUNlBUL3JiQUdqblBtVm1vWjRyYzdDZG9TOFpRWkpoCks4RUxBMTcrcG5NVGdvN3d4ZkFScUwrcCttcWd0VXhSYmlXaXRldjhGMmhVVkIvU3dQOGhwY0dyZGhURU43dGQKcFNXMXlrUGVHSkZLU0JvNVFIQW5xcVBGQ3pxdEZlb0w5RGhZeDUveEU2RnBLTUxnM3ZWY0ZzSHU2Z2xTOGlNVgo0SHZiMmZYdWhYeExUQkNiRDErNWxMUC9iSFhvZ0FLbXAySDZPajBlNldCbVEweHFHb3U0SWw2YmF2c1pDeDJ2CkFEV3ZsdWU1alhkTnU1eFBaZHNOVk5BbHVBbmUKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= ``` -------------------------------- ### Install Dependencies with npm Source: https://docs.spacelift.io/self-hosted/v2.0.0/vendors/pulumi/javascript This script installs all necessary Node.js dependencies for the Pulumi project before initialization. It ensures that all required packages are available in the workspace for subsequent Pulumi operations. ```bash npm install ``` -------------------------------- ### Create Slack App Manifest Example Source: https://docs.spacelift.io/self-hosted/v3.5.0/installing-spacelift/reference-architecture/reference/slack This JSON manifest is used to create a Slack app for integration with Spacelift. Replace `` with the domain hosting your self-hosted Spacelift instance. The app configuration includes display information, bot features, OAuth settings, and event subscriptions required for Spacelift to communicate with Slack. ```json { "display_information": { "name": "Spacelift", "description": "Taking your infra-as-code to the next level", "background_color": "#131417", "long_description": "Spacelift is a sophisticated and compliant infrastructure delivery platform for Terraform (including Terragrunt), Pulumi, CloudFormation, Ansible, and Kubernetes.\r\n\r\n• No lock-in. Under the hood, Spacelift uses your choice of Infrastructure as Code providers: open-source projects with vibrant ecosystems and a multitude of existing providers, modules, and tutorials.\r\n\r\n• Works with your Git flow. Spacelift integrates with GitHub (and other VCSes) to provide feedback on commits and Pull Requests, allowing you and your team to preview the changes before they are applied.\r\n\r\n• Drift detection. Spacelift natively detects drift, and can optionally revert it, to provide visibility and awareness to those \"changes\" that will inevitably happen.\r\n\r\n• Policy as a Code. With Open Policy Agent (OPA) Rego, you can programmatically define policies, approval flows, and various decision points within your Infrastructure as Code flow.\r\n\r\n• Customize your runtime. Spacelift uses Docker to run its workflows, which allows you to fully control your execution environment.\r\n\r\n• Share config using contexts. Spacelift contexts are collections of configuration files and environment variables that can be attached to multiple stacks.\r\n\r\n• Look ma, no credentials. Spacelift integrates with identity management systems from major cloud providers; AWS, Azure, and Google Cloud, allowing you to set up limited temporary access to your resources without the need to supply powerful static credentials.\r\n\r\n• Manage programmatically. With the Terraform provider, you can manage Spacelift resources as code.\r\n\r\n• Protect your state. Spacelift supports a sophisticated state backend and can optionally manage the state on your behalf." }, "features": { "bot_user": { "display_name": "Spacelift", "always_online": true }, "slash_commands": [ { "command": "/spacelift", "url": "https:///webhooks/slack", "description": "Get notified about Spacelift events", "usage_hint": "subscribe, unsubscribe or help", "should_escape": false } ] }, "oauth_config": { "redirect_urls": ["https:///slack_oauth"], "scopes": { "bot": [ "channels:read", "chat:write", "chat:write.public", "commands", "links:write", "team:read", "users:read" ] } }, "settings": { "event_subscriptions": { "request_url": "https:///webhooks/slack", "bot_events": ["app_uninstalled"] }, "interactivity": { "is_enabled": true, "request_url": "https:///webhooks/slack" }, "org_deploy_enabled": false, "socket_mode_enabled": false, "token_rotation_enabled": false } } ``` -------------------------------- ### Example Web Server Output Source: https://docs.spacelift.io/self-hosted/v2.2.0/vendors/pulumi/javascript This snippet shows a successful curl command to a deployed web server, demonstrating the 'Hello, World!' output. It verifies the web server is accessible via its public hostname. ```bash ~> curl ec2-18-184-240-9.eu-central-1.compute.amazonaws.com Hello, World! ```