-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Workload identity federation support for Fabric using STS #908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ea5dc46
a6ce8e3
c386d18
729877f
867906c
df1b63f
f455290
f08b80d
e109511
8b138eb
4fc425d
8f2fa06
40ff252
811fa16
ce910db
9054c86
2cbfe65
af0a15d
9570aa4
66e53b3
52bc166
ff310e1
84dd7a3
3b1c4fd
5dfacc8
922e768
f781395
6b2e817
bb15253
2f63589
d6fee57
a3ebaf6
3919dea
51633c7
822c63e
fd527b6
fd863c4
2989256
8c91948
b61eb5e
dd23de7
71e5d16
dce43ac
52bab5e
4d2b3da
43808f7
47cb8c9
1e2080a
da35e74
11431df
592e251
db3aa2e
cf3fc5d
bc0d0a9
9668f6c
44ce4b8
ac01068
02a99b3
d574de3
42f6ce9
7a82b0b
e483981
02f326f
825887c
b82f836
51bb1dc
b32d706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,8 +26,10 @@ on: | |
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| #actions: write required to update OIDC subject claim template | ||
| pull-requests: read | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
|
|
||
|
|
@@ -44,6 +46,8 @@ jobs: | |
| steps: | ||
| - run: true | ||
|
|
||
| # The GitHub OIDC subject claim template has been customized at the repository level to include only the workflow name. Long-term, we should consider using the default template for tests. | ||
|
|
||
| build: | ||
| name: Build | ||
| needs: authorize | ||
|
|
@@ -85,7 +89,6 @@ jobs: | |
| terraform: | ||
| - '1.5' | ||
| steps: | ||
|
|
||
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | ||
| with: | ||
|
|
@@ -161,7 +164,6 @@ jobs: | |
| terraform: | ||
| - '1.5' | ||
| steps: | ||
|
|
||
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | ||
| with: | ||
|
|
@@ -223,6 +225,81 @@ jobs: | |
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: ./coverage_pfcr.txt | ||
|
|
||
| test-STS-creds: | ||
| name: Matrix Test | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| EQUINIX_API_ENDPOINT: "https://uatapi.equinix.com" | ||
| EQUINIX_STS_ENDPOINT: "https://sts.uat.equinix.com" | ||
| timeout-minutes: 240 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| version: | ||
| - stable | ||
| terraform: | ||
| - '1.5' | ||
| sts_config: | ||
| - name: "default" | ||
| env_var_name: "EQUINIX_TOKEN_EXCHANGE_SUBJECT_TOKEN" | ||
| set_custom_env_var: false | ||
| token_exchange_subject_token_env_var: null | ||
| - name: "custom" | ||
| env_var_name: "CUSTOM_STS_TOKEN" | ||
| set_custom_env_var: true | ||
| token_exchange_subject_token_env_var: "CUSTOM_STS_TOKEN" | ||
| steps: | ||
| - id: get_id_token | ||
| name: Get GitHub OIDC Token for PFCR | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| try { | ||
| const idToken = await core.getIDToken('gha-fcr-client'); | ||
| console.log('Token generated with audience: gha-fcr-client'); | ||
| core.setOutput('id_token', idToken); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be using core.setSecret instead (which would influence how the value is referenced too)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it is required since Github automatically masks any value that looks like a token, which includes this one |
||
| } catch (error) { | ||
| console.error('Error getting OIDC token:', error.message); | ||
| core.setFailed(`Error getting OIDC token: ${error.message}`); | ||
| } | ||
| result-encoding: string | ||
|
|
||
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: './go.mod' | ||
| id: go | ||
|
|
||
| - name: Get dependencies | ||
| run: | | ||
| go mod download | ||
|
|
||
| - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | ||
| with: | ||
| terraform_version: ${{ matrix.terraform }} | ||
| terraform_wrapper: false | ||
|
|
||
| - name: TF Fabric PFCR acceptance tests STS creds | ||
| timeout-minutes: 180 | ||
ctreatma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env: | ||
| TF_ACC: "1" | ||
| TF_ACC_FABRIC_CONNECTIONS_TEST_DATA: ${{ secrets.TF_ACC_FABRIC_CONNECTIONS_TEST_DATA }} | ||
| TF_ACC_FABRIC_DEDICATED_PORTS: ${{ secrets.TF_ACC_FABRIC_DEDICATED_PORTS }} | ||
| TF_ACC_FABRIC_MARKET_PLACE_SUBSCRIPTION_ID: ${{ secrets.TF_ACC_FABRIC_MARKET_PLACE_SUBSCRIPTION_ID }} | ||
| TF_ACC_FABRIC_STREAM_TEST_DATA: ${{ secrets.TF_ACC_FABRIC_STREAM_TEST_DATA }} | ||
| EQUINIX_TOKEN_EXCHANGE_SCOPE: ${{ secrets.EQUINIX_STS_AUTH_SCOPE_PFCR }} | ||
| METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} | ||
| ${{ matrix.sts_config.env_var_name }}: ${{ steps.get_id_token.outputs.id_token }} | ||
| ${{ matrix.sts_config.set_custom_env_var && 'EQUINIX_TOKEN_EXCHANGE_SUBJECT_TOKEN_ENV_VAR' || 'SKIP' }}: ${{ matrix.sts_config.token_exchange_subject_token_env_var || '' }} | ||
| run: | | ||
displague marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| go test ./... --run "(TestAccFabricCreatePort2SPConnection_PFCR|TestAccCloudRouterCreateOnlyRequiredParameters_PFCR)" -v -coverprofile coverage_pfcr.txt -covermode=atomic -count 1 | ||
|
|
||
| upload-test-report: | ||
| name: Upload Testing Report | ||
| if: always() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Configuration for using Workload Identity Federation | ||
| provider "equinix" { | ||
| # Desired scope of the requested security token. Must be an Access Policy ERN or a string of the form `roleassignments:<organization_id>` | ||
| token_exchange_scope = "roleassignments:<organization_id>" | ||
|
|
||
| # The name of the environment variable containing the token exchange subject token | ||
| # For example, HCP Terraform automatically sets TFC_WORKLOAD_IDENTITY_TOKEN | ||
| token_exchange_subject_token_env_var = "TFC_WORKLOAD_IDENTITY_TOKEN" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.