Skip to content

Commit bd5d4a9

Browse files
authored
Merge pull request #121 from vimeda/tf-import
add terraform import to release workflow
2 parents 56fd9f6 + 5a13a07 commit bd5d4a9

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
role_name:
5+
required: true
6+
type: string
7+
role_session_name:
8+
required: true
9+
type: string
10+
aws_region:
11+
type: string
12+
required: false
13+
default: eu-central-1
14+
working_directory:
15+
required: true
16+
type: string
17+
resource_address:
18+
required: true
19+
type: string
20+
resource_id:
21+
required: true
22+
type: string
23+
24+
permissions:
25+
id-token: write
26+
contents: read
27+
pull-requests: write
28+
statuses: write
29+
30+
jobs:
31+
terraform-import:
32+
name: Terraform Import
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 15
35+
36+
defaults:
37+
run:
38+
working-directory: ${{ inputs.working_directory }}
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v3
43+
44+
- name: Configure AWS Credentials
45+
id: aws
46+
uses: aws-actions/configure-aws-credentials@v2
47+
with:
48+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.role_name }}
49+
role-session-name: ${{ inputs.role_session_name }}
50+
aws-region: ${{ inputs.aws_region }}
51+
52+
- name: Download Prod Variables
53+
uses: actions/download-artifact@v3
54+
with:
55+
name: prod-variables
56+
path: ${{ inputs.working_directory }}
57+
58+
- name: Setup Terraform
59+
uses: hashicorp/setup-terraform@v2
60+
with:
61+
terraform_version: ~1.0
62+
63+
- name: Terraform Init
64+
id: init
65+
run: terraform init
66+
67+
- name: Terraform Import Resource
68+
id: import
69+
run: terraform import '${{ inputs.resource_address }}' '${{ inputs.resource_id }}'

0 commit comments

Comments
 (0)