Skip to content

feat!: ssm integration - #227

Draft
Calvin-Cheng1 wants to merge 4 commits into
mainfrom
feat/ssm-integration
Draft

Calvin-Cheng1 wants to merge 4 commits into
mainfrom
feat/ssm-integration

Conversation

@Calvin-Cheng1

@Calvin-Cheng1 Calvin-Cheng1 commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # 198

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • FedRAMP Moderate
    • DoD IL4
    • DoD IL5
    • [] General / All
  • NIST 800-53r5 Controls: (If this PR helps satisfy or modifies control implementations, list them here)

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in documentation/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

Please describe the tests that you ran to verify your changes.

@Calvin-Cheng1 Calvin-Cheng1 changed the title Feat/ssm integration feat!: ssm integration Sep 17, 2026
@aghassemlouei aghassemlouei added Enhancement New feature or request Security Something is insecure or can be secured Priority - High Critical issues blocking development or users; urgent bugs or core features for release Level of Effort - High Complex task taking a week or more; consider breaking this down into smaller issues. labels Sep 18, 2026
@github-actions github-actions Bot added Type - Modules Scope - Fast Related to Fabric FAST deployment stages in the fast directory labels Sep 18, 2026
@aghassemlouei aghassemlouei added Scope - Module Related to reusable Terraform modules in the modules directory and removed Scope - Modules labels Sep 18, 2026
@github-actions github-actions Bot added Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Framework - FedRAMP High FedRAMP High compliance regime and controls Scope - Blueprint Related to solution blueprints in the blueprints directory Scope - Modules labels Oct 2, 2026

@aghassemlouei aghassemlouei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting together this draft to migrate CI/CD from Cloud Source Repositories to Secure Source Manager for #198. Because the branch is behind main and has a few structural and API issues, this review flags the main items to address before taking it out of draft, with click-to-apply suggestions on the inline threads.

  1. Rebase and drop upstream module changes: This branch is 83 commits behind main and conflicts in fast/stages-aw/0-bootstrap/automation.tf, modules/secure-source-manager-instance/main.tf, and modules/secure-source-manager-instance/versions.tf. The module refresh commit synced CFF v58.0.0 with >= 6.21.0, < 7.0.0, whereas main already synced modules/secure-source-manager-instance to CFF v60.0.0 in #311 with >= 8.10.0, < 9.0.0. Dropping the edits under modules/secure-source-manager-instance keeps the PR aligned with docs/upstream-sync.md and clears those module conflicts.

  2. Update CI/CD workflow templates and coordinate with #419: fast/stages-aw/0-bootstrap/templates/workflow-ssm.yaml and fast/stages-aw/1-resman/templates/workflow-ssm.yaml were renamed unchanged from workflow-sourcerepo.yaml. Both still pin _TF_VERSION to 1.7.6 despite versions.tf requiring >= 1.12.2, invoke gsutil instead of gcloud storage, and apply on push without a read-only plan flow. Consider aligning the template inputs with the service_accounts and tf_providers_files changes in #419 and checking fast/assets/templates/workflow-sourcerepo.yaml.

  3. Complete sourcerepo cleanup and PR metadata: Remaining Cloud Source Repositories references exist in modules/source-repository/, modules/README.md, docs/tdd.md, fast/docs/0-cicd-plan-sa.md, fast/stages-aw/0-bootstrap/README.md, fast/stages-aw/0-bootstrap/data/org-policies/cloudbuild_policy.yaml, and the source.developers.google.com. DNS entries in Stage 2 terraform.tfvars.sample. In the PR description, remove the space in "Fixes # 198" so GitHub links #198, add a breaking-change upgrade note, update fast/stages-aw/0-bootstrap/README.md, fill in "Testing Performed", and remove the unrelated "Scope - Blueprint" label and duplicate "FedRAMP Moderate" checkbox.

Comment on lines 72 to 75
"roles/securesourcemanager.instanceAccessor" = [
module.automation-tf-resman-sa.iam_email,
module.automation-tf-resman-r-sa.iam_email
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing roles/source.admin with roles/securesourcemanager.instanceAccessor on automation-tf-resman-sa has two consequences. First, every cicd-*.tf file in fast/stages-aw/1-resman still uses modules/source-repository, so removing roles/source.admin here breaks Stage 1 apply until those files are migrated. Second, once Stage 1 migrates to modules/secure-source-manager-instance, automation-tf-resman-sa needs repository-creation roles in addition to instance read access, specifically roles/securesourcemanager.instanceRepositoryCreator and roles/securesourcemanager.repoCreator on the automation project.

Suggested change
"roles/securesourcemanager.instanceAccessor" = [
module.automation-tf-resman-sa.iam_email,
module.automation-tf-resman-r-sa.iam_email
]
"roles/securesourcemanager.instanceAccessor" = [
module.automation-tf-resman-sa.iam_email,
module.automation-tf-resman-r-sa.iam_email
]
"roles/securesourcemanager.instanceRepositoryCreator" = [
module.automation-tf-resman-sa.iam_email
]
"roles/securesourcemanager.repoCreator" = [
module.automation-tf-resman-sa.iam_email
]

Comment on lines +71 to +97
source = "../../../modules/secure-source-manager-instance"
project_id = module.automation-project.project_id
location = "us-east1" #us-central1, us-east1
instance_id = "ssm-instance"

repositories = {
for k, v in local.cicd_repositories : v.name => {
description = "FAST Secure Source Manager repository for ${k} stage."
initial_config = {
default_branch = coalesce(v.branch, "main")
}
iam = {
"roles/securesourcemanager.repoAdmin" = [
k == "bootstrap"
? module.automation-tf-bootstrap-sa.iam_email
: module.automation-tf-resman-sa.iam_email
]
"roles/securesourcemanager.repoReader" = concat(
[module.automation-tf-cicd-sa[k].iam_email],
k == "bootstrap"
? [module.automation-tf-bootstrap-r-sa.iam_email]
: [module.automation-tf-resman-r-sa.iam_email]
)
}
} if v.type == "ssm"
}
project_id = module.automation-project.project_id
name = each.value.name
iam = {
"roles/source.admin" = [
each.key == "bootstrap"
? module.automation-tf-bootstrap-sa.iam_email
: module.automation-tf-resman-sa.iam_email
]
"roles/source.reader" = concat(
[module.automation-tf-cicd-sa[each.key].iam_email],
each.key == "bootstrap"
? [module.automation-tf-bootstrap-r-sa.iam_email]
: [module.automation-tf-resman-r-sa.iam_email]
)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module "automation-tf-cicd-repo" needs a conditional instance_create guard, configurable region and instance ID, and instance-level plus repository-level read access for both the apply and plan CI/CD service accounts. Because instance_create defaults to true, omitting it provisions an SSM instance on every Stage 0 deployment even when cicd_repositories is null or uses GitHub. Also note that var.regions.primary must be set to a supported SSM region when SSM is enabled, and DoD IL4 does not support SSM.

Suggested change
source = "../../../modules/secure-source-manager-instance"
project_id = module.automation-project.project_id
location = "us-east1" #us-central1, us-east1
instance_id = "ssm-instance"
repositories = {
for k, v in local.cicd_repositories : v.name => {
description = "FAST Secure Source Manager repository for ${k} stage."
initial_config = {
default_branch = coalesce(v.branch, "main")
}
iam = {
"roles/securesourcemanager.repoAdmin" = [
k == "bootstrap"
? module.automation-tf-bootstrap-sa.iam_email
: module.automation-tf-resman-sa.iam_email
]
"roles/securesourcemanager.repoReader" = concat(
[module.automation-tf-cicd-sa[k].iam_email],
k == "bootstrap"
? [module.automation-tf-bootstrap-r-sa.iam_email]
: [module.automation-tf-resman-r-sa.iam_email]
)
}
} if v.type == "ssm"
}
project_id = module.automation-project.project_id
name = each.value.name
iam = {
"roles/source.admin" = [
each.key == "bootstrap"
? module.automation-tf-bootstrap-sa.iam_email
: module.automation-tf-resman-sa.iam_email
]
"roles/source.reader" = concat(
[module.automation-tf-cicd-sa[each.key].iam_email],
each.key == "bootstrap"
? [module.automation-tf-bootstrap-r-sa.iam_email]
: [module.automation-tf-resman-r-sa.iam_email]
)
}
source = "../../../modules/secure-source-manager-instance"
project_id = module.automation-project.project_id
location = var.regions.primary
instance_id = "${local.prefix}-ssm-instance"
instance_create = anytrue([for k, v in local.cicd_repositories : v.type == "ssm"])
iam = anytrue([for k, v in local.cicd_repositories : v.type == "ssm"]) ? {
"roles/securesourcemanager.instanceAccessor" = flatten([
for k, v in local.cicd_repositories : [
module.automation-tf-cicd-sa[k].iam_email,
module.automation-tf-cicd-r-sa[k].iam_email
] if v.type == "ssm"
])
} : {}
repositories = {
for k, v in local.cicd_repositories : v.name => {
description = "FAST Secure Source Manager repository for ${k} stage."
initial_config = {
default_branch = coalesce(v.branch, "main")
}
iam = {
"roles/securesourcemanager.repoAdmin" = [
k == "bootstrap"
? module.automation-tf-bootstrap-sa.iam_email
: module.automation-tf-resman-sa.iam_email
]
"roles/securesourcemanager.repoReader" = [
module.automation-tf-cicd-sa[k].iam_email,
module.automation-tf-cicd-r-sa[k].iam_email,
k == "bootstrap"
? module.automation-tf-bootstrap-r-sa.iam_email
: module.automation-tf-resman-r-sa.iam_email
]
}
} if v.type == "ssm"
}
}

Comment thread fast/stages-aw/0-bootstrap/cicd.tf Outdated
Comment on lines 99 to 115
resource "google_cloudbuild_trigger" "automation-tf-cicd-trigger" {
for_each = {
for k, v in local.cicd_repositories : k => v if v.type == "ssm"
}
triggers = {
"fast-0-${each.key}" = {
filename = ".cloudbuild/workflow.yaml"
included_files = ["**/*tf", ".cloudbuild/workflow.yaml"]
service_account = module.automation-tf-cicd-sa[each.key].id
substitutions = {}
template = {
project_id = null
branch_name = each.value.branch
repo_name = each.value.name
tag_name = null
}
project = module.automation-project.project_id
name = "fast-0-${each.key}"

repository_event_config {
repository = module.automation-tf-cicd-repo.repositories[each.value.name].id
push {
branch = "^${coalesce(each.value.branch, "main")}$"
}
}

filename = ".cloudbuild/workflow.yaml"
service_account = module.automation-tf-cicd-sa[each.key].id
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google_cloudbuild_trigger with repository_event_config does not work with Secure Source Manager repositories and fails tflint.

  1. repository_event_config.repository expects a Cloud Build 2nd-gen Repository resource formatted as projects/*/locations/*/connections/*/repositories/*, not a Secure Source Manager repository ID. Native SSM integration triggers Cloud Build from an in-repo .cloudbuild/triggers.yaml file and requires granting the SSM service agent roles/cloudbuild.builds.editor and roles/serviceusage.serviceUsageConsumer on the build project plus roles/iam.serviceAccountUser on the custom Cloud Build service account. Note as well that fast/stages-aw/0-bootstrap/automation.tf only enables cloudbuild.googleapis.com when bootstrap_user is null, and fast/stages-aw/0-bootstrap/data/org-policies/cloudbuild_policy.yaml restricts cloudbuild.allowedIntegrations to github.com.

  2. tools/tflint.sh fails on "automation-tf-cicd-trigger" because terraform_naming_convention enforces snake_case resource names.

Suggested change
resource "google_cloudbuild_trigger" "automation-tf-cicd-trigger" {
for_each = {
for k, v in local.cicd_repositories : k => v if v.type == "ssm"
}
triggers = {
"fast-0-${each.key}" = {
filename = ".cloudbuild/workflow.yaml"
included_files = ["**/*tf", ".cloudbuild/workflow.yaml"]
service_account = module.automation-tf-cicd-sa[each.key].id
substitutions = {}
template = {
project_id = null
branch_name = each.value.branch
repo_name = each.value.name
tag_name = null
}
project = module.automation-project.project_id
name = "fast-0-${each.key}"
repository_event_config {
repository = module.automation-tf-cicd-repo.repositories[each.value.name].id
push {
branch = "^${coalesce(each.value.branch, "main")}$"
}
}
filename = ".cloudbuild/workflow.yaml"
service_account = module.automation-tf-cicd-sa[each.key].id
}
resource "google_project_iam_member" "ssm_service_agent_cloudbuild" {
for_each = toset(
anytrue([for k, v in local.cicd_repositories : v.type == "ssm"])
? ["roles/cloudbuild.builds.editor", "roles/serviceusage.serviceUsageConsumer"]
: []
)
project = module.automation-project.project_id
role = each.value
member = "serviceAccount:service-${module.automation-project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com"
}
resource "google_service_account_iam_member" "ssm_service_agent_cicd_sa_user" {
for_each = {
for k, v in local.cicd_repositories : k => v if v.type == "ssm"
}
service_account_id = module.automation-tf-cicd-sa[each.key].name
role = "roles/iam.serviceAccountUser"
member = "serviceAccount:service-${module.automation-project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com"
}

Comment on lines 21 to 27
module "branch-network-cicd-repo" {
source = "../../../modules/source-repository"
for_each = (
try(local.cicd_repositories.networking.type, null) == "sourcerepo"
try(local.cicd_repositories.networking.type, null) == "ssm"
? { 0 = local.cicd_repositories.networking }
: {}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seven fast/stages-aw/1-resman/cicd-*.tf files (cicd-data-platform.tf, cicd-gcve.tf, cicd-gke.tf, cicd-networking.tf, cicd-project-factory.tf, cicd-security.tf, and cicd-teams.tf) switched "sourcerepo" to "ssm" while keeping source = "../../../modules/source-repository", roles/source.admin, roles/source.reader, and Cloud Source Repository triggers. Each block needs to move to ../../../modules/secure-source-manager-instance with instance_create = false and updated SSM IAM roles. Because GitHub restricts suggestions to lines inside the diff hunk (21..27), remove the legacy source-repository arguments on lines 28..49 immediately below after applying this suggestion, and apply the same pattern across the remaining six 1-resman/cicd-*.tf files.

Suggested change
module "branch-network-cicd-repo" {
source = "../../../modules/source-repository"
for_each = (
try(local.cicd_repositories.networking.type, null) == "sourcerepo"
try(local.cicd_repositories.networking.type, null) == "ssm"
? { 0 = local.cicd_repositories.networking }
: {}
)
module "branch-network-cicd-repo" {
source = "../../../modules/secure-source-manager-instance"
for_each = (
try(local.cicd_repositories.networking.type, null) == "ssm"
? { 0 = local.cicd_repositories.networking }
: {}
)
project_id = var.automation.project_id
location = var.regions.primary
instance_id = "${var.prefix}-prod-ssm-instance"
instance_create = false
repositories = {
(each.value.name) = {
description = "FAST Secure Source Manager repository for networking stage."
initial_config = {
default_branch = coalesce(each.value.branch, "main")
}
iam = {
"roles/securesourcemanager.repoAdmin" = [
module.branch-network-sa.iam_email
]
"roles/securesourcemanager.repoReader" = [
module.branch-network-sa-cicd[0].iam_email,
module.branch-network-r-sa-cicd[0].iam_email
]
}
}
}
depends_on = [
module.branch-network-sa-cicd,
module.branch-network-r-sa-cicd
]
}

@github-actions github-actions Bot added the Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request Framework - FedRAMP High FedRAMP High compliance regime and controls Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Level of Effort - High Complex task taking a week or more; consider breaking this down into smaller issues. Priority - High Critical issues blocking development or users; urgent bugs or core features for release Scope - Blueprint Related to solution blueprints in the blueprints directory Scope - Fast Related to Fabric FAST deployment stages in the fast directory Scope - Module Related to reusable Terraform modules in the modules directory Security Something is insecure or can be secured

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants