spaceforge 1.2.1__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spaceforge-1.2.1 → spaceforge-1.3.0}/.github/workflows/ci.yml +1 -1
- {spaceforge-1.2.1/spaceforge.egg-info → spaceforge-1.3.0}/PKG-INFO +3 -4
- spaceforge-1.3.0/plugins/aws_sam/README.md +43 -0
- spaceforge-1.3.0/plugins/aws_sam/plugin.py +142 -0
- spaceforge-1.3.0/plugins/aws_sam/plugin.yaml +238 -0
- spaceforge-1.3.0/plugins/aws_sam/requirements.txt +1 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/checkov/plugin.py +2 -1
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/checkov/plugin.yaml +4 -2
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/infracost/plugin.py +2 -1
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/infracost/plugin.yaml +4 -2
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/sops/plugin.py +46 -9
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/sops/plugin.yaml +67 -11
- spaceforge-1.3.0/plugins/ssm_parameter_store/README.md +271 -0
- spaceforge-1.3.0/plugins/ssm_parameter_store/plugin.py +273 -0
- spaceforge-1.3.0/plugins/ssm_parameter_store/plugin.yaml +504 -0
- spaceforge-1.3.0/plugins/ssm_parameter_store/requirements.txt +1 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/terrascan/plugin.py +2 -1
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/terrascan/plugin.yaml +4 -2
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trivy/plugin.py +2 -1
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trivy/plugin.yaml +4 -2
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/wiz/plugin.py +4 -3
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/wiz/plugin.yaml +8 -6
- {spaceforge-1.2.1 → spaceforge-1.3.0}/pyproject.toml +9 -7
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/_version_scm.py +3 -3
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/cls.py +2 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/schema.json +16 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_generator.py +6 -12
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_generator_core.py +2 -4
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_runner.py +22 -44
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_runner_cli.py +2 -4
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_runner_core.py +2 -4
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_runner_execution.py +6 -12
- {spaceforge-1.2.1 → spaceforge-1.3.0/spaceforge.egg-info}/PKG-INFO +3 -4
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge.egg-info/SOURCES.txt +8 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge.egg-info/requires.txt +1 -1
- {spaceforge-1.2.1 → spaceforge-1.3.0}/.github/workflows/release.yml +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/.gitignore +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/CONTRIBUTING.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/LICENSE +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/MANIFEST.in +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/go.mod +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/linting/__init__.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/linting/spaceforge_checker.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/checkov/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/checkov/requirements.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/enviroment_manager/plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/enviroment_manager/plugin.yaml +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/enviroment_manager/requirements.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/envsubst/plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/envsubst/plugin.yaml +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/opentofu-tracing/plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/opentofu-tracing/plugin.yaml +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/sops/requirements.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/terrascan/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trivy/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trufflehog/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trufflehog/plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/plugins/trufflehog/plugin.yaml +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/regenerate_plugins.sh +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/setup.cfg +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/README.md +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/__init__.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/__main__.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/_version.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/conftest.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/generator.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/runner.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/templates/binary_install.sh.j2 +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/templates/ensure_spaceforge_and_run.sh.j2 +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_cls.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_generator_binaries.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_generator_hooks.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_generator_parameters.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_plugin.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_plugin_file_operations.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_plugin_hooks.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge/test_plugin_inheritance.py +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge.egg-info/dependency_links.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge.egg-info/entry_points.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/spaceforge.egg-info/top_level.txt +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/templates.go +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/test.sh +0 -0
- {spaceforge-1.2.1 → spaceforge-1.3.0}/validate_plugins.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spaceforge
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A Python framework for building Spacelift plugins
|
|
5
5
|
Author-email: Spacelift <support@spacelift.io>
|
|
6
6
|
Maintainer-email: Spacelift <support@spacelift.io>
|
|
@@ -14,13 +14,12 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
21
|
Classifier: Topic :: System :: Systems Administration
|
|
23
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.10
|
|
24
23
|
Description-Content-Type: text/markdown
|
|
25
24
|
License-File: LICENSE
|
|
26
25
|
Requires-Dist: PyYAML>=6.0
|
|
@@ -31,7 +30,7 @@ Requires-Dist: mergedeep>=1.3.4
|
|
|
31
30
|
Provides-Extra: dev
|
|
32
31
|
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
33
32
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
-
Requires-Dist: black; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=26.1.0; extra == "dev"
|
|
35
34
|
Requires-Dist: isort; extra == "dev"
|
|
36
35
|
Requires-Dist: mypy; extra == "dev"
|
|
37
36
|
Requires-Dist: pylint; extra == "dev"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# AWS SAM Plugin
|
|
2
|
+
|
|
3
|
+
Packages AWS SAM templates into CloudFormation templates for Spacelift's CloudFormation integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This plugin runs `sam package` before initialization to convert SAM templates to CloudFormation,
|
|
8
|
+
enabling you to deploy serverless applications through Spacelift's CloudFormation workflow.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
- A CloudFormation stack configured in Spacelift
|
|
13
|
+
- SAM template in your repository
|
|
14
|
+
- S3 bucket for template storage (configured via Spacelift CloudFormation settings)
|
|
15
|
+
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
### Parameters
|
|
19
|
+
|
|
20
|
+
| Parameter | Description | Default |
|
|
21
|
+
|-----------|-------------|---------|
|
|
22
|
+
| S3 Prefix | S3 prefix for SAM artifacts | `sam-artifacts` |
|
|
23
|
+
| Additional Arguments | Extra arguments for `sam package` | (empty) |
|
|
24
|
+
|
|
25
|
+
### Required Environment Variables
|
|
26
|
+
|
|
27
|
+
These are automatically set by Spacelift's CloudFormation integration:
|
|
28
|
+
|
|
29
|
+
- `CF_METADATA_REGION`: AWS region
|
|
30
|
+
- `CF_METADATA_TEMPLATE_BUCKET`: S3 bucket for templates
|
|
31
|
+
- `CF_METADATA_ENTRY_TEMPLATE_FILE`: Output template path
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
1. Create a CloudFormation stack in Spacelift pointing to your SAM template
|
|
36
|
+
2. Install and attach this plugin to the stack
|
|
37
|
+
3. The plugin automatically packages your SAM template before each run
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- [Spacelift CloudFormation Getting Started](https://docs.spacelift.io/vendors/cloudformation/getting-started)
|
|
42
|
+
- [Spacelift CloudFormation Reference](https://docs.spacelift.io/vendors/cloudformation/reference)
|
|
43
|
+
- [AWS SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from spaceforge import Context, Parameter, SpaceforgePlugin, Variable
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AwsSamPlugin(SpaceforgePlugin):
|
|
7
|
+
"""
|
|
8
|
+
The AWS SAM plugin packages SAM templates into CloudFormation templates
|
|
9
|
+
for use with Spacelift's CloudFormation integration.
|
|
10
|
+
|
|
11
|
+
This plugin runs `sam package` before initialization to:
|
|
12
|
+
- Package the SAM application
|
|
13
|
+
- Upload artifacts to S3
|
|
14
|
+
- Generate a CloudFormation template for Spacelift to process
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
1. Install the plugin in your Spacelift account
|
|
19
|
+
2. Attach it to CloudFormation stacks using SAM templates
|
|
20
|
+
3. Configure the required environment variables via Spacelift contexts
|
|
21
|
+
4. The plugin runs automatically before init, generating the CF template
|
|
22
|
+
|
|
23
|
+
## Required Environment Variables
|
|
24
|
+
|
|
25
|
+
These are typically set by Spacelift's CloudFormation integration:
|
|
26
|
+
- `CF_METADATA_REGION`: AWS region for packaging
|
|
27
|
+
- `CF_METADATA_TEMPLATE_BUCKET`: S3 bucket for template storage
|
|
28
|
+
- `CF_METADATA_ENTRY_TEMPLATE_FILE`: Output template file path
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
- **S3 Prefix**: Prefix for SAM artifacts in S3 (default: `sam-artifacts`)
|
|
33
|
+
- **Additional Arguments**: Extra arguments to pass to `sam package`
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
__plugin_name__ = "AWS SAM"
|
|
37
|
+
__author__ = "tetienne"
|
|
38
|
+
__version__ = "1.0.0"
|
|
39
|
+
__labels__ = ["cloudformation", "sam", "serverless"]
|
|
40
|
+
|
|
41
|
+
__parameters__ = [
|
|
42
|
+
Parameter(
|
|
43
|
+
name="S3 Prefix",
|
|
44
|
+
id="sam_s3_prefix",
|
|
45
|
+
description="S3 prefix for SAM artifacts",
|
|
46
|
+
default="sam-artifacts",
|
|
47
|
+
type="string",
|
|
48
|
+
required=False,
|
|
49
|
+
),
|
|
50
|
+
Parameter(
|
|
51
|
+
name="Additional Arguments",
|
|
52
|
+
id="sam_additional_args",
|
|
53
|
+
description="Additional command-line arguments to pass to sam package",
|
|
54
|
+
default="",
|
|
55
|
+
type="string",
|
|
56
|
+
required=False,
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
__contexts__ = [
|
|
61
|
+
Context(
|
|
62
|
+
name_prefix="aws_sam",
|
|
63
|
+
description="AWS SAM Plugin",
|
|
64
|
+
env=[
|
|
65
|
+
Variable(
|
|
66
|
+
key="SAM_S3_PREFIX",
|
|
67
|
+
value_from_parameter="sam_s3_prefix",
|
|
68
|
+
),
|
|
69
|
+
Variable(
|
|
70
|
+
key="SAM_ADDITIONAL_ARGS",
|
|
71
|
+
value_from_parameter="sam_additional_args",
|
|
72
|
+
),
|
|
73
|
+
],
|
|
74
|
+
)
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
def before_init(self):
|
|
78
|
+
"""
|
|
79
|
+
Execute sam package before Spacelift initialization.
|
|
80
|
+
|
|
81
|
+
This generates the CloudFormation template from the SAM template,
|
|
82
|
+
uploading artifacts to S3 and outputting the packaged template
|
|
83
|
+
for Spacelift's CloudFormation flow.
|
|
84
|
+
"""
|
|
85
|
+
try:
|
|
86
|
+
# Get required environment variables
|
|
87
|
+
region = os.environ.get("CF_METADATA_REGION")
|
|
88
|
+
template_bucket = os.environ.get("CF_METADATA_TEMPLATE_BUCKET")
|
|
89
|
+
output_template = os.environ.get("CF_METADATA_ENTRY_TEMPLATE_FILE")
|
|
90
|
+
|
|
91
|
+
if not region:
|
|
92
|
+
self.logger.error("CF_METADATA_REGION environment variable is required")
|
|
93
|
+
exit(1)
|
|
94
|
+
if not template_bucket:
|
|
95
|
+
self.logger.error(
|
|
96
|
+
"CF_METADATA_TEMPLATE_BUCKET environment variable is required"
|
|
97
|
+
)
|
|
98
|
+
exit(1)
|
|
99
|
+
if not output_template:
|
|
100
|
+
self.logger.error(
|
|
101
|
+
"CF_METADATA_ENTRY_TEMPLATE_FILE environment variable is required"
|
|
102
|
+
)
|
|
103
|
+
exit(1)
|
|
104
|
+
|
|
105
|
+
# Get optional configuration
|
|
106
|
+
s3_prefix = os.environ.get("SAM_S3_PREFIX", "sam-artifacts")
|
|
107
|
+
additional_args = os.environ.get("SAM_ADDITIONAL_ARGS", "").strip()
|
|
108
|
+
|
|
109
|
+
# Build sam package command
|
|
110
|
+
args = [
|
|
111
|
+
"package",
|
|
112
|
+
"--region",
|
|
113
|
+
region,
|
|
114
|
+
"--s3-bucket",
|
|
115
|
+
template_bucket,
|
|
116
|
+
"--s3-prefix",
|
|
117
|
+
s3_prefix,
|
|
118
|
+
"--output-template-file",
|
|
119
|
+
output_template,
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
# Add additional arguments if provided
|
|
123
|
+
if additional_args:
|
|
124
|
+
args.extend(additional_args.split())
|
|
125
|
+
|
|
126
|
+
# Execute sam package
|
|
127
|
+
self.logger.info(f"Running: sam {' '.join(args)}")
|
|
128
|
+
return_code, stdout, stderr = self.run_cli("sam", *args)
|
|
129
|
+
|
|
130
|
+
if return_code != 0:
|
|
131
|
+
self.logger.error(f"sam package failed with exit code {return_code}")
|
|
132
|
+
if stderr:
|
|
133
|
+
self.logger.error("Error output: " + "\n".join(stderr))
|
|
134
|
+
exit(1)
|
|
135
|
+
|
|
136
|
+
self.logger.info(
|
|
137
|
+
f"Successfully generated CloudFormation template: {output_template}"
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
except Exception as e:
|
|
141
|
+
self.logger.error(f"Plugin failed: {e}")
|
|
142
|
+
exit(1)
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
name: AWS SAM
|
|
2
|
+
version: 1.0.0
|
|
3
|
+
description: |-
|
|
4
|
+
The AWS SAM plugin packages SAM templates into CloudFormation templates
|
|
5
|
+
for use with Spacelift's CloudFormation integration.
|
|
6
|
+
|
|
7
|
+
This plugin runs `sam package` before initialization to:
|
|
8
|
+
- Package the SAM application
|
|
9
|
+
- Upload artifacts to S3
|
|
10
|
+
- Generate a CloudFormation template for Spacelift to process
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
1. Install the plugin in your Spacelift account
|
|
15
|
+
2. Attach it to CloudFormation stacks using SAM templates
|
|
16
|
+
3. Configure the required environment variables via Spacelift contexts
|
|
17
|
+
4. The plugin runs automatically before init, generating the CF template
|
|
18
|
+
|
|
19
|
+
## Required Environment Variables
|
|
20
|
+
|
|
21
|
+
These are typically set by Spacelift's CloudFormation integration:
|
|
22
|
+
- `CF_METADATA_REGION`: AWS region for packaging
|
|
23
|
+
- `CF_METADATA_TEMPLATE_BUCKET`: S3 bucket for template storage
|
|
24
|
+
- `CF_METADATA_ENTRY_TEMPLATE_FILE`: Output template file path
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
- **S3 Prefix**: Prefix for SAM artifacts in S3 (default: `sam-artifacts`)
|
|
29
|
+
- **Additional Arguments**: Extra arguments to pass to `sam package`
|
|
30
|
+
author: tetienne
|
|
31
|
+
labels:
|
|
32
|
+
- cloudformation
|
|
33
|
+
- sam
|
|
34
|
+
- serverless
|
|
35
|
+
parameters:
|
|
36
|
+
- name: S3 Prefix
|
|
37
|
+
description: S3 prefix for SAM artifacts
|
|
38
|
+
type: string
|
|
39
|
+
sensitive: false
|
|
40
|
+
required: false
|
|
41
|
+
default: sam-artifacts
|
|
42
|
+
id: sam_s3_prefix
|
|
43
|
+
- name: Additional Arguments
|
|
44
|
+
description: Additional command-line arguments to pass to sam package
|
|
45
|
+
type: string
|
|
46
|
+
sensitive: false
|
|
47
|
+
required: false
|
|
48
|
+
default: ''
|
|
49
|
+
id: sam_additional_args
|
|
50
|
+
contexts:
|
|
51
|
+
- name_prefix: aws_sam
|
|
52
|
+
description: AWS SAM Plugin
|
|
53
|
+
env:
|
|
54
|
+
- key: SAM_S3_PREFIX
|
|
55
|
+
value_from_parameter: sam_s3_prefix
|
|
56
|
+
sensitive: false
|
|
57
|
+
- key: SAM_ADDITIONAL_ARGS
|
|
58
|
+
value_from_parameter: sam_additional_args
|
|
59
|
+
sensitive: false
|
|
60
|
+
mounted_files:
|
|
61
|
+
- path: /mnt/workspace/plugins/aws_sam/requirements.txt
|
|
62
|
+
content: |-
|
|
63
|
+
aws-sam-cli==1.148.0
|
|
64
|
+
sensitive: false
|
|
65
|
+
- path: /mnt/workspace/plugins/aws_sam/plugin.py
|
|
66
|
+
content: |-
|
|
67
|
+
import os
|
|
68
|
+
|
|
69
|
+
from spaceforge import Context, Parameter, SpaceforgePlugin, Variable
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class AwsSamPlugin(SpaceforgePlugin):
|
|
73
|
+
"""
|
|
74
|
+
The AWS SAM plugin packages SAM templates into CloudFormation templates
|
|
75
|
+
for use with Spacelift's CloudFormation integration.
|
|
76
|
+
|
|
77
|
+
This plugin runs `sam package` before initialization to:
|
|
78
|
+
- Package the SAM application
|
|
79
|
+
- Upload artifacts to S3
|
|
80
|
+
- Generate a CloudFormation template for Spacelift to process
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
1. Install the plugin in your Spacelift account
|
|
85
|
+
2. Attach it to CloudFormation stacks using SAM templates
|
|
86
|
+
3. Configure the required environment variables via Spacelift contexts
|
|
87
|
+
4. The plugin runs automatically before init, generating the CF template
|
|
88
|
+
|
|
89
|
+
## Required Environment Variables
|
|
90
|
+
|
|
91
|
+
These are typically set by Spacelift's CloudFormation integration:
|
|
92
|
+
- `CF_METADATA_REGION`: AWS region for packaging
|
|
93
|
+
- `CF_METADATA_TEMPLATE_BUCKET`: S3 bucket for template storage
|
|
94
|
+
- `CF_METADATA_ENTRY_TEMPLATE_FILE`: Output template file path
|
|
95
|
+
|
|
96
|
+
## Configuration
|
|
97
|
+
|
|
98
|
+
- **S3 Prefix**: Prefix for SAM artifacts in S3 (default: `sam-artifacts`)
|
|
99
|
+
- **Additional Arguments**: Extra arguments to pass to `sam package`
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
__plugin_name__ = "AWS SAM"
|
|
103
|
+
__author__ = "tetienne"
|
|
104
|
+
__version__ = "1.0.0"
|
|
105
|
+
__labels__ = ["cloudformation", "sam", "serverless"]
|
|
106
|
+
|
|
107
|
+
__parameters__ = [
|
|
108
|
+
Parameter(
|
|
109
|
+
name="S3 Prefix",
|
|
110
|
+
id="sam_s3_prefix",
|
|
111
|
+
description="S3 prefix for SAM artifacts",
|
|
112
|
+
default="sam-artifacts",
|
|
113
|
+
type="string",
|
|
114
|
+
required=False,
|
|
115
|
+
),
|
|
116
|
+
Parameter(
|
|
117
|
+
name="Additional Arguments",
|
|
118
|
+
id="sam_additional_args",
|
|
119
|
+
description="Additional command-line arguments to pass to sam package",
|
|
120
|
+
default="",
|
|
121
|
+
type="string",
|
|
122
|
+
required=False,
|
|
123
|
+
),
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
__contexts__ = [
|
|
127
|
+
Context(
|
|
128
|
+
name_prefix="aws_sam",
|
|
129
|
+
description="AWS SAM Plugin",
|
|
130
|
+
env=[
|
|
131
|
+
Variable(
|
|
132
|
+
key="SAM_S3_PREFIX",
|
|
133
|
+
value_from_parameter="sam_s3_prefix",
|
|
134
|
+
),
|
|
135
|
+
Variable(
|
|
136
|
+
key="SAM_ADDITIONAL_ARGS",
|
|
137
|
+
value_from_parameter="sam_additional_args",
|
|
138
|
+
),
|
|
139
|
+
],
|
|
140
|
+
)
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
def before_init(self):
|
|
144
|
+
"""
|
|
145
|
+
Execute sam package before Spacelift initialization.
|
|
146
|
+
|
|
147
|
+
This generates the CloudFormation template from the SAM template,
|
|
148
|
+
uploading artifacts to S3 and outputting the packaged template
|
|
149
|
+
for Spacelift's CloudFormation flow.
|
|
150
|
+
"""
|
|
151
|
+
try:
|
|
152
|
+
# Get required environment variables
|
|
153
|
+
region = os.environ.get("CF_METADATA_REGION")
|
|
154
|
+
template_bucket = os.environ.get("CF_METADATA_TEMPLATE_BUCKET")
|
|
155
|
+
output_template = os.environ.get("CF_METADATA_ENTRY_TEMPLATE_FILE")
|
|
156
|
+
|
|
157
|
+
if not region:
|
|
158
|
+
self.logger.error("CF_METADATA_REGION environment variable is required")
|
|
159
|
+
exit(1)
|
|
160
|
+
if not template_bucket:
|
|
161
|
+
self.logger.error(
|
|
162
|
+
"CF_METADATA_TEMPLATE_BUCKET environment variable is required"
|
|
163
|
+
)
|
|
164
|
+
exit(1)
|
|
165
|
+
if not output_template:
|
|
166
|
+
self.logger.error(
|
|
167
|
+
"CF_METADATA_ENTRY_TEMPLATE_FILE environment variable is required"
|
|
168
|
+
)
|
|
169
|
+
exit(1)
|
|
170
|
+
|
|
171
|
+
# Get optional configuration
|
|
172
|
+
s3_prefix = os.environ.get("SAM_S3_PREFIX", "sam-artifacts")
|
|
173
|
+
additional_args = os.environ.get("SAM_ADDITIONAL_ARGS", "").strip()
|
|
174
|
+
|
|
175
|
+
# Build sam package command
|
|
176
|
+
args = [
|
|
177
|
+
"package",
|
|
178
|
+
"--region",
|
|
179
|
+
region,
|
|
180
|
+
"--s3-bucket",
|
|
181
|
+
template_bucket,
|
|
182
|
+
"--s3-prefix",
|
|
183
|
+
s3_prefix,
|
|
184
|
+
"--output-template-file",
|
|
185
|
+
output_template,
|
|
186
|
+
]
|
|
187
|
+
|
|
188
|
+
# Add additional arguments if provided
|
|
189
|
+
if additional_args:
|
|
190
|
+
args.extend(additional_args.split())
|
|
191
|
+
|
|
192
|
+
# Execute sam package
|
|
193
|
+
self.logger.info(f"Running: sam {' '.join(args)}")
|
|
194
|
+
return_code, stdout, stderr = self.run_cli("sam", *args)
|
|
195
|
+
|
|
196
|
+
if return_code != 0:
|
|
197
|
+
self.logger.error(f"sam package failed with exit code {return_code}")
|
|
198
|
+
if stderr:
|
|
199
|
+
self.logger.error("Error output: " + "\n".join(stderr))
|
|
200
|
+
exit(1)
|
|
201
|
+
|
|
202
|
+
self.logger.info(
|
|
203
|
+
f"Successfully generated CloudFormation template: {output_template}"
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
except Exception as e:
|
|
207
|
+
self.logger.error(f"Plugin failed: {e}")
|
|
208
|
+
exit(1)
|
|
209
|
+
sensitive: false
|
|
210
|
+
- path: /mnt/workspace/plugins/aws_sam/before_init.sh
|
|
211
|
+
content: |-
|
|
212
|
+
#!/bin/sh
|
|
213
|
+
|
|
214
|
+
set -e
|
|
215
|
+
|
|
216
|
+
cd /mnt/workspace/plugins/aws_sam
|
|
217
|
+
|
|
218
|
+
if [ ! -d "./venv" ]; then
|
|
219
|
+
python -m venv --system-site-packages ./venv
|
|
220
|
+
fi
|
|
221
|
+
. venv/bin/activate
|
|
222
|
+
|
|
223
|
+
if ! command -v spaceforge; then
|
|
224
|
+
pip install spaceforge
|
|
225
|
+
fi
|
|
226
|
+
|
|
227
|
+
if [ -f requirements.txt ] && [ ! -f .spaceforge_installed_requirements ]; then
|
|
228
|
+
pip install -r requirements.txt
|
|
229
|
+
touch .spaceforge_installed_requirements
|
|
230
|
+
fi
|
|
231
|
+
|
|
232
|
+
cd /mnt/workspace/source/$TF_VAR_spacelift_project_root
|
|
233
|
+
python -m spaceforge run --plugin-file /mnt/workspace/plugins/aws_sam/plugin.py before_init
|
|
234
|
+
sensitive: false
|
|
235
|
+
hooks:
|
|
236
|
+
before_init:
|
|
237
|
+
- mkdir -p /mnt/workspace/plugins/aws_sam
|
|
238
|
+
- chmod +x /mnt/workspace/plugins/aws_sam/before_init.sh && /mnt/workspace/plugins/aws_sam/before_init.sh
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aws-sam-cli==1.148.0
|
|
@@ -77,7 +77,7 @@ class CheckovPlugin(SpaceforgePlugin):
|
|
|
77
77
|
|
|
78
78
|
__plugin_name__ = "Checkov"
|
|
79
79
|
__author__ = "Spacelift"
|
|
80
|
-
__version__ = "1.0.
|
|
80
|
+
__version__ = "1.0.4"
|
|
81
81
|
__labels__ = ["security", "terraform"]
|
|
82
82
|
|
|
83
83
|
__parameters__ = [
|
|
@@ -109,6 +109,7 @@ class CheckovPlugin(SpaceforgePlugin):
|
|
|
109
109
|
name_prefix="checkov",
|
|
110
110
|
type="PLAN",
|
|
111
111
|
labels=["checkov"],
|
|
112
|
+
engine_type="REGO_V0",
|
|
112
113
|
body="""package spacelift
|
|
113
114
|
|
|
114
115
|
import rego.v1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: Checkov
|
|
2
|
-
version: 1.0.
|
|
2
|
+
version: 1.0.4
|
|
3
3
|
description: |-
|
|
4
4
|
This plugin runs Checkov security scanning on Terraform/OpenTofu configurations
|
|
5
5
|
during the after_plan hook and reports findings with detailed resource-level
|
|
@@ -173,7 +173,7 @@ contexts:
|
|
|
173
173
|
|
|
174
174
|
__plugin_name__ = "Checkov"
|
|
175
175
|
__author__ = "Spacelift"
|
|
176
|
-
__version__ = "1.0.
|
|
176
|
+
__version__ = "1.0.4"
|
|
177
177
|
__labels__ = ["security", "terraform"]
|
|
178
178
|
|
|
179
179
|
__parameters__ = [
|
|
@@ -205,6 +205,7 @@ contexts:
|
|
|
205
205
|
name_prefix="checkov",
|
|
206
206
|
type="PLAN",
|
|
207
207
|
labels=["checkov"],
|
|
208
|
+
engine_type="REGO_V0",
|
|
208
209
|
body="""package spacelift
|
|
209
210
|
|
|
210
211
|
import rego.v1
|
|
@@ -508,5 +509,6 @@ policies:
|
|
|
508
509
|
checkov_data.summary.low == 0
|
|
509
510
|
checkov_data.summary.total_failed > max_critical
|
|
510
511
|
}
|
|
512
|
+
engine_type: REGO_V0
|
|
511
513
|
labels:
|
|
512
514
|
- checkov
|
|
@@ -9,7 +9,7 @@ class InfracostPlugin(SpaceforgePlugin):
|
|
|
9
9
|
# Plugin metadata
|
|
10
10
|
__plugin_name__ = "Infracost"
|
|
11
11
|
__labels__ = ["cost estimation", "infrastructure"]
|
|
12
|
-
__version__ = "1.0.
|
|
12
|
+
__version__ = "1.0.3"
|
|
13
13
|
__author__ = "Spacelift Team"
|
|
14
14
|
|
|
15
15
|
__parameters__ = [
|
|
@@ -46,6 +46,7 @@ class InfracostPlugin(SpaceforgePlugin):
|
|
|
46
46
|
Policy(
|
|
47
47
|
name_prefix="INFRACOST",
|
|
48
48
|
type="PLAN",
|
|
49
|
+
engine_type="REGO_V0",
|
|
49
50
|
body="""
|
|
50
51
|
package spacelift
|
|
51
52
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: Infracost
|
|
2
|
-
version: 1.0.
|
|
2
|
+
version: 1.0.3
|
|
3
3
|
description: A plugin for integrating with Infracost to estimate costs of infrastructure changes.
|
|
4
4
|
author: Spacelift Team
|
|
5
5
|
labels:
|
|
@@ -33,7 +33,7 @@ contexts:
|
|
|
33
33
|
# Plugin metadata
|
|
34
34
|
__plugin_name__ = "Infracost"
|
|
35
35
|
__labels__ = ["cost estimation", "infrastructure"]
|
|
36
|
-
__version__ = "1.0.
|
|
36
|
+
__version__ = "1.0.3"
|
|
37
37
|
__author__ = "Spacelift Team"
|
|
38
38
|
|
|
39
39
|
__parameters__ = [
|
|
@@ -70,6 +70,7 @@ contexts:
|
|
|
70
70
|
Policy(
|
|
71
71
|
name_prefix="INFRACOST",
|
|
72
72
|
type="PLAN",
|
|
73
|
+
engine_type="REGO_V0",
|
|
73
74
|
body="""
|
|
74
75
|
package spacelift
|
|
75
76
|
|
|
@@ -148,3 +149,4 @@ policies:
|
|
|
148
149
|
# Learn more about sampling policy evaluations here:
|
|
149
150
|
# https://docs.spacelift.io/concepts/policy#sampling-policy-inputs
|
|
150
151
|
sample := true
|
|
152
|
+
engine_type: REGO_V0
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
|
|
3
4
|
import yaml
|
|
4
5
|
from sopsy import Sops, SopsyError
|
|
5
6
|
|
|
6
|
-
from spaceforge import Binary, SpaceforgePlugin
|
|
7
|
+
from spaceforge import Binary, Context, Parameter, SpaceforgePlugin, Variable
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class SopsPlugin(SpaceforgePlugin):
|
|
@@ -34,12 +35,20 @@ class SopsPlugin(SpaceforgePlugin):
|
|
|
34
35
|
secrets:
|
|
35
36
|
- test_secret.yaml
|
|
36
37
|
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Use the "Config File Path" parameter to specify the location of your `.sops.yaml` file.
|
|
42
|
+
This is useful when your stack's `project_root` is set to a subdirectory but the `.sops.yaml`
|
|
43
|
+
file is at the repository root.
|
|
44
|
+
|
|
45
|
+
Example: `${TF_VAR_spacelift_workspace_root}/source/.sops.yaml`
|
|
37
46
|
"""
|
|
38
47
|
|
|
39
48
|
# Plugin metadata
|
|
40
49
|
__plugin_name__ = "Sops"
|
|
41
50
|
__labels__ = ["secrets management", "encryption"]
|
|
42
|
-
__version__ = "1.
|
|
51
|
+
__version__ = "1.1.1"
|
|
43
52
|
__author__ = "Spacelift Team"
|
|
44
53
|
|
|
45
54
|
__binaries__ = [
|
|
@@ -52,20 +61,48 @@ class SopsPlugin(SpaceforgePlugin):
|
|
|
52
61
|
)
|
|
53
62
|
]
|
|
54
63
|
|
|
64
|
+
__parameters__ = [
|
|
65
|
+
Parameter(
|
|
66
|
+
name="Config File Path",
|
|
67
|
+
id="sops_config_path",
|
|
68
|
+
description="Path to the .sops.yaml configuration file. Defaults to .sops.yaml in the working directory. Use an absolute path (e.g., /mnt/workspace/source/.sops.yaml) when the config file is at the repository root but the stack uses a project_root subdirectory.",
|
|
69
|
+
default=".sops.yaml",
|
|
70
|
+
type="string",
|
|
71
|
+
required=False,
|
|
72
|
+
),
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
__contexts__ = [
|
|
76
|
+
Context(
|
|
77
|
+
name_prefix="sops",
|
|
78
|
+
description="Main context for Sops",
|
|
79
|
+
env=[
|
|
80
|
+
Variable(
|
|
81
|
+
key="SOPS_CONFIG_PATH",
|
|
82
|
+
value_from_parameter="sops_config_path",
|
|
83
|
+
),
|
|
84
|
+
],
|
|
85
|
+
)
|
|
86
|
+
]
|
|
87
|
+
|
|
55
88
|
def before_init(self):
|
|
56
|
-
|
|
57
|
-
|
|
89
|
+
# Get config path from environment variable or use default
|
|
90
|
+
config_path = os.environ.get("SOPS_CONFIG_PATH", ".sops.yaml").strip()
|
|
91
|
+
config_file = Path(config_path)
|
|
92
|
+
|
|
93
|
+
if not config_file.exists():
|
|
94
|
+
self.logger.error(f"No config file found at: {config_path}")
|
|
58
95
|
return
|
|
59
96
|
|
|
60
|
-
secrets =
|
|
97
|
+
secrets = config_file.read_text()
|
|
61
98
|
try:
|
|
62
99
|
secrets = yaml.safe_load(secrets)
|
|
63
100
|
except yaml.YAMLError as e:
|
|
64
|
-
self.logger.error(f"Failed to parse
|
|
101
|
+
self.logger.error(f"Failed to parse {config_path}: {e}")
|
|
65
102
|
return
|
|
66
103
|
|
|
67
104
|
if "secrets" not in secrets:
|
|
68
|
-
self.logger.error("No secrets key found in .
|
|
105
|
+
self.logger.error(f"No secrets key found in {config_path}.")
|
|
69
106
|
return
|
|
70
107
|
secrets = secrets["secrets"]
|
|
71
108
|
|
|
@@ -75,10 +112,10 @@ class SopsPlugin(SpaceforgePlugin):
|
|
|
75
112
|
continue
|
|
76
113
|
|
|
77
114
|
try:
|
|
78
|
-
self.logger.
|
|
115
|
+
self.logger.info(f"Decrypting secret {secret}.")
|
|
79
116
|
sops = Sops(Path(secret), in_place=True)
|
|
80
117
|
sops.decrypt()
|
|
81
|
-
self.logger.
|
|
118
|
+
self.logger.info("Decryption successful.")
|
|
82
119
|
except SopsyError as e:
|
|
83
120
|
self.logger.error(f"Failed to decrypt secret: {e}")
|
|
84
121
|
except Exception as e:
|