DB@AWS · TERRAFORM · GITHUB ACTIONS

Provision Oracle Autonomous Database Serverless on AWS with Terraform and GitHub Actions

Share on LinkedIn ↗

This guide explains how to provision Oracle Autonomous Database Serverless on AWS using Terraform and GitHub Actions, then connect securely from Windows SQL Developer.

Start by configuring AWS Marketplace onboarding, Oracle account activation, IAM and SCP permissions, and GitHub OIDC integration. Then create a VPC, ODB network, ODB peering connection, and an EC2 client for Session Manager port forwarding.

Finally, provision the database, configure the wallet connection in SQL Developer, and run SQL queries to verify the database identity and Oracle version. The completed setup provides a reusable plan, review, and apply process for future deployments.

Follow the guide in this order. Each stage produces something needed by the next stage.

Stage Where you work What you finish with
1. Subscribe and activate AWS Marketplace and Oracle An activated Oracle Database@AWS account
2. Get the repositories GitHub and Windows Local copies and access to run their workflows
3. Set up the network workflow Windows PowerShell, then GitHub Settings AWS roles, S3 storage, repository variables, and environments
4. Create the network and EC2 client GitHub Actions ODB network ID, VPC ID, and EC2 instance ID
5. Set up and run the database workflow Windows PowerShell, then GitHub Actions An AVAILABLE database and its database ID
6. Connect and verify Windows, SSM, and SQL Developer An open tunnel and successful SQL queries
7. Reuse the workflow GitHub Actions Another named deployment using the same reviewed process

Start with subscription and Oracle activation

Complete the AWS Marketplace subscription and activate the Oracle account before provisioning the ODB network or database.

Review the offer and subscribe

Sign in to the workload AWS account, open AWS Marketplace, and locate Oracle Database@AWS. Open the available offer and review its pricing, payment terms, and license agreement before subscribing.

Choose the purchase-order option required by your organization. Set auto-renewal according to your requirements; it remained On in the verified lab. The purchase screen showed a USD 0.00 upfront contract total, with usage billed separately. Running databases, networking, and EC2 can still incur charges.

Oracle Database AWS options
Subscription options. Review the purchase-order setting, auto-renewal preference, and usage-based charges before selecting Subscribe.

Select Subscribe and wait for the purchase confirmation. Confirm that the page displays Your subscription is confirmed and the green successful-purchase banner.

Oracle Database AWS confirmed
Purchase confirmation. The successful subscription provides the Set up your account action.

Set up the Oracle account

On the purchase confirmation page, select Set up your account. If AWS displays a session selector, choose the workload account that owns the Marketplace subscription and will own the database resources. Use the organization management account separately when editing SCPs.

In the Oracle Database@AWS Get started panel, follow the activation action. The verified lab displayed Activate new Oracle account. Follow the available activation flow for a new or existing Oracle account as appropriate.

Oracle Database AWS activate
Oracle activation. The Dashboard remains unavailable while Oracle account activation is pending.

Wait for the account ready confirmation

Complete the Oracle activation form. If Oracle displays that the cloud account is being created, wait for the account-ready email before proceeding. Keep activation links and tokens private.

The confirmation email states that the new cloud account has been created and includes a Sign In action.

Oracle Database AWS ready
Account ready. Oracle confirms that account creation is complete.

Return to Oracle Database@AWS and refresh the Get started panel. Once activation is complete, select Dashboard to continue.

Oracle Database AWS Dashboard ready
Oracle Database@AWS is ready. Select Dashboard to continue.

Architecture and connection flow

GitHub Actions runs Terraform to create the AWS network, EC2 instance, and database. After these resources are ready, use SQL Developer on your Windows computer to connect to the database.

Oracle Database AWS architecture
GitHub Actions creates the resources. SQL Developer connects to the database through EC2.

The database has a private address, so your Windows computer cannot connect to it directly. EC2 acts as the bridge: an SSM tunnel sends SQL Developer traffic to EC2, and ODB peering connects EC2's VPC to the database network.

Use AWS Session Manager to open this secure tunnel. You do not need PuTTY, an SSH key, or an inbound SSH port on EC2.

Component Value used in this lab
AWS Region us-east-1, US East N. Virginia
Physical Availability Zone ID use1-az6
Network deployment network-01
Application VPC CIDR Hidden
ODB client CIDR Hidden
ODB backup CIDR Hidden
EC2 client Amazon Linux 2023, t3.micro
Database deployment adbs-lab-01
Database name ADBSLAB01
Database capacity 2 ECPUs and 20 GB
Authentication mTLS with a client wallet
Compute and storage autoscaling Disabled

Choose private CIDR ranges that do not overlap with existing VPCs, ODB networks, VPNs, or other connected networks.

ADB Serverless does not require you to provision dedicated Exadata infrastructure or an Autonomous VM cluster. This lab uses an ODB network, ODB peering, and an Autonomous Database Serverless instance. The verified lab used physical AZ use1-az6; the account-specific AZ name appeared as us-east-1d. Check physical AZ IDs rather than assuming that an AZ letter means the same location in every account. For an overview of the service and its architecture, see the Oracle Database@AWS documentation.

Prerequisites and permissions

Before running the workflows, complete the AWS Marketplace subscription and Oracle account activation described above. Choose a supported Region and Availability Zone, and reserve non-overlapping private CIDRs for the application VPC, ODB client network, and backup network. Use Oracle’s Oracle Database@AWS prerequisites and permissions guide as the main reference for the ODB network, peering, IAM permissions, and organization policy requirements.

Check SCPs and permissions boundaries

Both AWS Service Control Policies (SCPs) and permissions boundaries can limit a user’s effective permissions. Oracle AI Database@AWS onboarding and provisioning can therefore fail even when the user’s IAM policy allows the required actions. SCPs apply organization-level controls, while permissions boundaries limit the permissions available to individual IAM users or roles. Review both before provisioning. See Oracle’s prerequisites note, Service control policies (SCPs), Permissions boundaries for IAM entities, and Evaluating identity-based policies with resource-based policies.

SCP update confirmation

Before provisioning, ensure your organization’s SCPs permit the required onboarding and deployment operations.

Prepare the IAM permissions

Ensure the setup identity can create the IAM roles and storage used by Terraform, and the deployment roles can manage the lab resources. The EC2 client also needs Systems Manager permissions. Review the repository’s bootstrap policies alongside Oracle’s prerequisites guide before starting.

Separate network infrastructure from databases

Use separate repositories for networking and database deployments:

The separation lets several databases share a network and keeps database cleanup from deleting shared networking. A new deployment name selects a separate configuration and Terraform state. Reusing an existing name manages the existing deployment.

For example, the database repository stores state under:

deployments/adbs-lab-01/terraform.tfstate
deployments/adbs-lab-02/terraform.tfstate

Repository access is required before continuing. These source repositories are private. Obtain access and create or use the copies authorized for your GitHub account. A reader without the source files cannot reproduce the workflows from this article alone. In the commands below, use the owner and repository names of the copies that will run your workflows.

Prepare AWS CLI and Terraform on Windows

Complete this setup for the network repository first. The database repository gets its own setup later, after the network is available. Run PowerShell code blocks with their Copy button; do not paste headings, captions, or Markdown fence labels.

1. Install and verify the tools

Install AWS CLI v2 for Windows, Terraform, Git for Windows, and GitHub CLI. Git downloads the source; GitHub CLI reads your repository’s identity settings. Reopen PowerShell after installation. The verified lab used Terraform 1.16.6 and AWS provider 6.72.0; keep the repository’s pinned versions.

terraform version
& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" --version
git --version
gh --version
Verify AWS CLI and Terraform on Windows
The lab’s version check. Confirm that each installed tool runs before continuing.

2. Sign in to AWS and GitHub

In Windows PowerShell, run the AWS login command and complete the browser sign-in for your workload account:

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" login --profile odb-lab --region us-east-1

The browser confirms that credentials were shared with the CLI. Keep this PowerShell window open. If the profile expires later, rerun this login command.

AWS CLI sign-in confirmation

Then authenticate GitHub CLI with the account that owns or can administer your workflow repositories:

gh auth login --hostname github.com --web
gh auth status

These are separate logins: AWS authorizes the local Terraform setup; GitHub lets you download and inspect the repositories. Neither login stores AWS access keys in GitHub.

3. Verify the AWS account and Oracle activation

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" sts get-caller-identity --profile odb-lab --region us-east-1
& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb get-oci-onboarding-status --profile odb-lab --region us-east-1 --query "{status:status}" --output json --no-cli-pager

Checkpoint: the caller is your workload account and Oracle onboarding is ACTIVE.

Verify CLI authentication and Oracle onboarding

4. Run the Terraform bootstrap locally

The bootstrap is the one-time Terraform setup that creates the GitHub OIDC provider, workflow roles, EC2 instance role/profile, and S3 state storage. It does not create the VPC, ODB network, or database.

Download your network repository. Replace YOUR_GITHUB_OWNER with the owner of your authorized repository copy. Run these commands in a folder where you want to keep the source:

$networkRepository = "YOUR_GITHUB_OWNER/oracledb-aws-network-actions"
gh repo clone $networkRepository
Set-Location .\oracledb-aws-network-actions
Test-Path .\bootstrap\main.tf

The final command must return True. All bootstrap commands below run from this repository root.

Get the repository’s OIDC subject prefix before creating the input file:

gh api "repos/$networkRepository/actions/oidc/customization/sub"

Copy the returned sub_claim_prefix into github_oidc_subject_prefix. Use your repository’s value exactly. The verified lab’s prefix included immutable GitHub owner and repository IDs; those IDs change when you create a different repository. If your response or repository’s subject configuration differs, verify it using GitHub’s OIDC reference before applying the trust policy.

Create bootstrap\bootstrap.tfvars.json. Open the file:

notepad .\bootstrap\bootstrap.tfvars.json

Paste and save this JSON with your own values:

{
  "aws_account_id": "YOUR_AWS_ACCOUNT_ID",
  "state_region": "us-east-1",
  "state_bucket": "YOUR_UNIQUE_NETWORK_STATE_BUCKET",
  "github_repository": "YOUR_GITHUB_OWNER/oracledb-aws-network-actions",
  "github_oidc_subject_prefix": "YOUR_EXACT_REPOSITORY_OIDC_SUBJECT_PREFIX"
}

The network configuration used in this lab, with the AWS account masked, was:

{
  "aws_account_id": "<AWS_ACCOUNT_ID>",
  "state_region": "us-east-1",
  "state_bucket": "odbnet-tfstate-<AWS_ACCOUNT_ID>-us-east-1",
  "github_repository": "venkatcloudlearner-cell/oracledb-aws-network-actions",
  "github_oidc_subject_prefix": "repo:venkatcloudlearner-cell@349041879/oracledb-aws-network-actions@1447296506"
}

What happens to state_bucket? Terraform creates this S3 bucket during apply; you do not create it manually. Choose an available, globally unique name. The bucket stores workflow state, deployment settings, and saved plans, with encryption, versioning, public-access blocking, and HTTPS-only access. The bootstrap’s own state remains locally in bootstrap; keep it private and backed up.

If this AWS account already has GitHub’s OIDC provider, add existing_oidc_provider_arn to the JSON, using its ARN from IAM → Identity providers. Otherwise the network bootstrap creates it.

Initialize and generate the setup plan:

$env:AWS_PROFILE = "odb-lab"
terraform '-chdir=bootstrap' init
terraform '-chdir=bootstrap' plan '-var-file=bootstrap.tfvars.json' '-out=bootstrap.tfplan'

If Terraform reports an authentication error despite a successful CLI login, use this optional workaround in the same PowerShell window, then retry the plan:

$credential = (& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" configure export-credentials --profile odb-lab --format process) | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) { throw "AWS credential export failed. Sign in again." }
$env:AWS_ACCESS_KEY_ID = $credential.AccessKeyId
$env:AWS_SECRET_ACCESS_KEY = $credential.SecretAccessKey
$env:AWS_SESSION_TOKEN = $credential.SessionToken

These temporary credentials are for local Terraform only. Do not print them or copy them into GitHub.

Review the plan, then create the setup resources:

terraform '-chdir=bootstrap' apply bootstrap.tfplan
terraform '-chdir=bootstrap' output -json github_variables

Wait for Apply complete. The final command prints the five values used in step 5:

{
  "AWS_ACCOUNT_ID": "YOUR_AWS_ACCOUNT_ID",
  "AWS_APPLY_ROLE_ARN": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/odbnet-github-apply",
  "AWS_PLAN_ROLE_ARN": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/odbnet-github-plan",
  "STATE_REGION": "us-east-1",
  "TF_STATE_BUCKET": "YOUR_CREATED_NETWORK_STATE_BUCKET"
}

This is the handoff: your input file → Terraform creates AWS roles and storage → Terraform prints outputs → you add those outputs to GitHub. Use the values from your own output, rather than the placeholders above. You can redisplay them at any time with terraform '-chdir=bootstrap' output -json github_variables.

5. Add the bootstrap outputs to GitHub

Open your network repository → Settings → Secrets and variables → Actions → Variables. Select New repository variable and add each name below with its corresponding Terraform output:

Variable Value to copy
AWS_ACCOUNT_ID Your workload account ID
AWS_PLAN_ROLE_ARN The created network plan role ARN
AWS_APPLY_ROLE_ARN The created network apply role ARN
STATE_REGION The state bucket Region
TF_STATE_BUCKET The created network state bucket name
GitHub repository variables from bootstrap outputs

Under Settings → Environments, create terraform-plan and terraform-apply. In each environment, configure deployment branch restrictions to permit main. The names must match the workflow files and IAM trust policies.

Checkpoint: this repository has all five variables and both environments. No AWS access key, secret key, or session token is stored as a repository variable.

6. Run a reviewed workflow plan and apply

The setup is complete. Continue to Provision the VPC and ODB network for the first deployment inputs. A plan previews changes; it does not create the network. After a successful plan, use its run ID and attempt in the separate Apply reviewed plan workflow.

The next OIDC section shows how to verify what this setup created. You do not need to create the same provider or roles manually.

Verify the GitHub and AWS integration

Step 4 above created the AWS side of the integration, and step 5 configured GitHub. Use the following views to verify that setup. Each workflow uses OIDC to obtain its own temporary AWS credentials.

How the lab’s GitHub to AWS connection was configured

1. Terraform registered GitHub as an identity provider in AWS. The network repository’s bootstrap/main.tf creates the IAM OIDC provider with:

In Prepare AWS CLI and Terraform on Windows → Step 4: Run the Terraform bootstrap locally, running terraform '-chdir=bootstrap' apply bootstrap.tfplan executed the code in bootstrap/main.tf and created the GitHub OIDC identity provider in AWS IAM. We did not add it manually in the AWS console. You can verify the provider under IAM → Identity providers → token.actions.githubusercontent.com. The database repository’s setup uses this same provider by supplying its ARN as existing_oidc_provider_arn, rather than creating another one.

GitHub OIDC identity provider and AWS STS audience
IAM → Identity providers → token.actions.githubusercontent.com shows the OpenID Connect provider and sts.amazonaws.com audience.

2. Terraform created separate plan and apply roles. The network roles are odbnet-github-plan and odbnet-github-apply. Their permission policies define what each workflow can do. Their trust policies define which GitHub jobs can assume them.

The plan role trusts this lab’s repository and planning environment:

{
  "Effect": "Allow",
  "Principal": {
    "Federated": "arn:aws:iam::<AWS_ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
  },
  "Action": "sts:AssumeRoleWithWebIdentity",
  "Condition": {
    "StringEquals": {
      "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
      "token.actions.githubusercontent.com:sub": "repo:venkatcloudlearner-cell@349041879/oracledb-aws-network-actions@1447296506:environment:terraform-plan"
    }
  }
}

This is a trust-policy statement with the account ID masked. The apply role uses the same repository prefix with :environment:terraform-apply. You can inspect each policy under IAM → Roles → select the role → Trust relationships.

GitHub plan role trust relationships
IAM → Roles → odbnet-github-plan → Trust relationships shows the GitHub repository and terraform-plan environment permitted to assume the role.

The apply role is shown below. Its subject ends in :environment:terraform-apply, matching the apply workflow’s GitHub environment.

GitHub apply role trust relationships
IAM → Roles → odbnet-github-apply → Trust relationships permits this repository’s terraform-apply jobs to assume the apply role.

3. Confirm the GitHub settings. Check that this repository has the five variables from its own bootstrap outputs and the environments terraform-plan and terraform-apply, restricted to main. The plan and apply role ARNs must belong to this repository’s setup.

4. The workflow requests an OIDC token and assumes its AWS role. The network planning job contains the following settings, excerpted from .github/workflows/network.yml:

environment: terraform-plan
permissions:
  contents: read
  id-token: write
steps:
  - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
    with:
      role-to-assume: ${{ vars.AWS_PLAN_ROLE_ARN }}
      aws-region: ${{ vars.STATE_REGION }}
      role-duration-seconds: 21600
      role-session-name: odbnet-plan-${{ github.run_id }}

id-token: write lets the job request its GitHub identity token. The credentials action sends that token to AWS STS. AWS checks the provider, audience, and exact repository/environment subject before issuing temporary credentials. Terraform then uses those credentials to access AWS. The apply job follows the same process using its apply environment and role.

5. The successful plan run verified the connection. Once the workflow authenticated and completed its Terraform plan, the GitHub-to-AWS integration was working. No access key, secret key, or session token was stored in the repository variables.

The connection flow is GitHub job → GitHub OIDC token → AWS STS checks the role trust policy → temporary AWS credentials → Terraform. See GitHub’s OIDC with AWS guide.

Plan first and apply the saved plan

The repositories deliberately separate planning from applying. Run a plan, review its changes, then dispatch Apply reviewed plan using that run's ID and attempt.

The apply workflow verifies the source workflow, successful result, branch, source commit, deployment, and plan age before applying the saved plan. Plans older than 24 hours require a fresh plan. The separate manual apply dispatch was useful because required-reviewer environment protection was unavailable on this private repository's GitHub plan.

Provision the VPC and ODB network

After configuring authentication, open Actions → ODB network stacks → Run workflow.

For a new network stack, enter the following values. Replace each CIDR placeholder with a non-overlapping private range approved for your environment. Use a currently supported physical Availability Zone ID; use1-az6 is the location verified in this lab. The form’s three CIDR values must be real ranges before you select Run workflow.

Workflow input Value
deployment_id network-01
operation plan
region us-east-1
availability_zone_id use1-az6
vpc_cidr YOUR_VPC_CIDR
client_cidr YOUR_ODB_CLIENT_CIDR
backup_cidr YOUR_ODB_BACKUP_CIDR
EC2 client instance (client_vm_mode) Keep current setting
enable_managed_dns false
confirm_destroy blank
ODB network workflow first-run inputs
Actions → ODB network stacks → Run workflow. For the first network run, leave EC2 client instance at Keep current setting and managed DNS unchecked. The earlier form shown here used the internal value keep for this choice.

For a new network deployment, Keep current setting leaves the optional EC2 client disabled. Enable the client later when it is needed for connection testing.

The network workflow creates the application VPC and subnet, an internet gateway and route table, the ODB network, and an ODB peering connection between the VPC and the ODB network. Routes for the ODB client and backup CIDRs direct traffic through this peering connection. This is the path the EC2 client uses to reach the private database. Managed DNS and optional S3 integrations stayed disabled.

Open the successful plan run and read its plan summary. Save the displayed run ID and attempt number. Then select Actions → Apply reviewed plan → Run workflow, use branch main, and enter:

Apply input Value
deployment_id network-01
plan_run_id The run ID from your successful network plan
plan_run_attempt The attempt shown in that plan’s summary
confirm_deployment network-01

Run the workflow and wait for Success. In its Completed summary, save odb_network_id and vpc_id. You will use the network ID when creating the database. Use your own run ID; screenshot run IDs are historical examples.

Verify ODB peering and VPC routes

Display network provisioning status in PowerShell:

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb list-odb-networks `
  --profile odb-lab --region us-east-1 `
  --query "odbNetworks[].{Name:displayName,Status:status}" `
  --output table --no-cli-pager

Wait for AVAILABLE, then check the peering connection and VPC route table. An available ODB network alone does not prove that an application VPC has a working route to it.

Use odb_network_id and vpc_id from the successful network apply summary. The following read-only checks find the matching peering and route tables; you do not need peering or route-table IDs from Terraform outputs:

$networkId = "YOUR_ODB_NETWORK_ID"
$vpcId = "YOUR_VPC_ID"

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb get-odb-network --odb-network-id $networkId --profile odb-lab --region us-east-1 --query "odbNetwork.{Name:displayName,Status:status}" --output table --no-cli-pager

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb list-odb-peering-connections --profile odb-lab --region us-east-1 --query "odbPeeringConnections[?displayName=='network-01-peering'].{Name:displayName,Status:status,Peer:peerNetworkArn}" --output table --no-cli-pager

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ec2 describe-route-tables --filters "Name=vpc-id,Values=$vpcId" --profile odb-lab --region us-east-1 --query "RouteTables[].{Table:RouteTableId,Routes:Routes[].{Destination:DestinationCidrBlock,State:State}}" --output json --no-cli-pager

Checkpoint: the ODB network and its peering show AVAILABLE, the peer ARN identifies your application VPC, and the routes for the client and backup CIDRs entered in the workflow show active. Adjust the peering name in the filter if you used another deployment name.

ODB network peering and route verification
Network verification. PowerShell confirms that the ODB network and peering are available and the client and backup routes are active.

Provision the EC2 client instance

Open the network repository → Actions → ODB network stacks → Run workflow. Choose deployment_id=network-01, operation=plan, and EC2 client instance → Create EC2. Leave the AZ and all CIDR fields blank so the existing settings reload. Leave managed DNS off and destruction confirmation blank.

EC2 client instance field with Create EC2 selected
Reuse network-01, choose Create EC2 for the EC2 client, and leave the AZ and CIDR inputs blank to retain the existing network settings.

Review the plan, then run Apply reviewed plan with this new plan’s run ID and attempt, and network-01 as both deployment and confirmation. After success, save client_instance_id from the Completed summary. This is the instance ID used by the SSM and tunnel commands.

The reviewed plan created exactly one t3.micro instance without changing the VPC or ODB network. The apply finished in 1m 3s.

ec2 apply success
The EC2-only apply completed while retaining the existing network resources.

The client uses Amazon Linux 2023, an encrypted 8 GB gp3 volume, IMDSv2, standard CPU credits, and the SSM instance profile. Its security group has no inbound SSH or RDP rules. Outbound rules allow HTTPS for management and database traffic to the ODB client CIDR.

For this small lab, the instance has a public IPv4 address for outbound access through the internet gateway. That avoids a NAT Gateway, but the public IPv4 address still has a cost. A public IP does not itself open an inbound port.

A guest timer stops the instance 60 minutes after each boot. Verify the timer in Linux using the commands below. It stops active sessions too, so account for it during longer SQL Developer sessions.

Open Systems Manager and confirm the client is ready

Before using EC2 as the tunnel host, confirm that SSM reports the instance as Online:

$instanceId = "YOUR_CLIENT_INSTANCE_ID"

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ssm describe-instance-information `
  --profile odb-lab --region us-east-1 `
  --filters "Key=InstanceIds,Values=$instanceId" `
  --query "InstanceInformationList[].{Connection:PingStatus,Agent:AgentVersion,Platform:PlatformName}" `
  --output table --no-cli-pager

The observed agent version was 3.3.5700.0, on Amazon Linux, with connection status Online.

To open a browser shell, go to AWS Systems Manager → Node Tools → Session Manager → Start Session.

ssm open start
Session Manager is the entry point for the browser shell.

Select network-01-client and confirm that it shows Online and running. Choose Next, leave the optional session document blank, then continue to Review and launch → Start session. AWS also provides a direct Start session option in the target step. AWS session instructions

ssm select target
Selecting the managed EC2 client before opening a session.

Inside the shell, run:

whoami
cat /etc/os-release | head -n 2
systemctl is-active amazon-ssm-agent
systemctl is-enabled lab-autostop.timer
ssm session blog
The real browser session shows ssm-user, Amazon Linux 2023, an active SSM agent, and the enabled auto-stop timer.

The interactive shell ran as ssm-user. A separate SSM Run Command check ran as root; those are different execution contexts.

Create the Autonomous Database Serverless instance

Set up the database repository before its first run

The database workflow has its own roles, bucket, GitHub variables, and environments. Completing network setup does not configure this repository.

Open PowerShell in the parent folder where you keep your repositories. Sign in to AWS again if needed, then download the database repository:

$dbRepository = "YOUR_GITHUB_OWNER/oracledb-aws-adbs-actions"
gh repo clone $dbRepository
Set-Location .\oracledb-aws-adbs-actions
gh api "repos/$dbRepository/actions/oidc/customization/sub"
notepad .\bootstrap\bootstrap.tfvars.json

Save the following JSON with your workload account, a different available bucket name, and the database repository’s exact sub_claim_prefix from the API response. Use the existing OIDC provider ARN from IAM → Identity providers → token.actions.githubusercontent.com:

{
  "aws_account_id": "YOUR_AWS_ACCOUNT_ID",
  "state_region": "us-east-1",
  "state_bucket": "YOUR_UNIQUE_DATABASE_STATE_BUCKET",
  "github_repository": "YOUR_GITHUB_OWNER/oracledb-aws-adbs-actions",
  "github_oidc_subject_prefix": "YOUR_DATABASE_REPOSITORY_SUBJECT_PREFIX",
  "existing_oidc_provider_arn": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com"
}

In this lab the database repository was venkatcloudlearner-cell/oracledb-aws-adbs-actions, its prefix was repo:venkatcloudlearner-cell@349041879/oracledb-aws-adbs-actions@1447272002, and the bucket name followed adbs-tfstate-<AWS_ACCOUNT_ID>-us-east-1. Replace these identities for your own repository.

From the database repository root, run:

$env:AWS_PROFILE = "odb-lab"
terraform '-chdir=bootstrap' init
terraform '-chdir=bootstrap' plan '-var-file=bootstrap.tfvars.json' '-out=bootstrap.tfplan'

Review the plan, then run:

terraform '-chdir=bootstrap' apply bootstrap.tfplan
terraform '-chdir=bootstrap' output -json github_variables

Add those five outputs to the database repository’s Actions variables. Create its terraform-plan and terraform-apply environments and restrict them to main, just as in network setup. Use the database role ARNs and database bucket from this output; do not copy the network repository’s values.

Checkpoint: the database repository has its own five variables and two environments. Keep its bootstrap state private and backed up. Create the ADMIN password secret next.

Configure the database

The database repository uses aws_odb_autonomous_database, with the existing ODB network ID supplied as an input. It does not manage that shared network.

The Terraform resource is already included in the database repository. You do not need to create another resource block. This excerpt shows the settings managed by the workflow:

resource "aws_odb_autonomous_database" "this" {
  source                              = "NONE"
  odb_network_id                      = var.odb_network_id
  db_name                             = var.db_name
  display_name                        = var.deployment_id
  db_workload                         = "OLTP"
  db_version                          = var.db_version
  compute_count                       = 2
  data_storage_size_in_gbs            = 20
  license_model                       = "LICENSE_INCLUDED"
  is_auto_scaling_enabled             = false
  is_auto_scaling_for_storage_enabled = false
  is_mtls_connection_required         = true
  admin_password_wo                   = var.admin_password
  admin_password_wo_version           = 1
}

The repository declares the ADMIN password input as sensitive and ephemeral and uses the provider's write-only password field. The password is supplied again to the apply workflow rather than embedded in the saved Terraform plan. This behavior depends on those specific Terraform/provider features; an ordinary sensitive variable alone does not keep a value out of state.

In the database repository, open Settings → Secrets and variables → Actions → Secrets → New repository secret. Use the name ADBS_ADMIN_PASSWORD and enter the database ADMIN password privately. The repository requires 12–30 characters, and the password must also meet Oracle’s complexity requirements. Keep this password available for the later SQL Developer login. Workflow inputs use the secret’s name, never the password value. Pinned AWS provider resource reference

Run the database plan

In Actions → ADB-S databases → Run workflow, enter:

Workflow input Value
deployment_id adbs-lab-01
operation plan
region us-east-1
odb_network_id Existing network-01 ID from Terraform
db_name ADBSLAB01
compute_count 2
storage_gb 20
db_version blank, allowing the service default
password_secret ADBS_ADMIN_PASSWORD
confirm_destroy blank

The successful plan proposed 1 create, 0 updates, 0 deletions.

adbs plan success
The database plan creates one ADB-S instance on the existing ODB network.

In the database repository, open Actions → Apply reviewed plan → Run workflow, branch main. Set deployment_id=adbs-lab-01, password_secret=ADBS_ADMIN_PASSWORD, and confirm_deployment=adbs-lab-01. Copy plan_run_id and plan_run_attempt from your successful database plan summary. Start the workflow and wait for Success.

Save database_id from the Completed summary. Checkpoint: the returned status is AVAILABLE. This database ID is needed by the Windows connection commands.

The apply completed successfully in 16m 56s.

adbs apply success
GitHub Actions completed the saved plan and returned database status AVAILABLE.

Check the actual database settings

Verify the resource independently through AWS CLI:

$databaseId = "YOUR_AUTONOMOUS_DATABASE_ID"

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb get-autonomous-database `
  --autonomous-database-id $databaseId --profile odb-lab --region us-east-1 `
  --query "autonomousDatabase.{Name:displayName,Status:status,Compute:computeCount,Model:computeModel,StorageGB:dataStorageSizeInGBs,Version:dbVersion,AutoCompute:isAutoScalingEnabled,AutoStorage:isAutoScalingForStorageEnabled,MTLS:isMtlsConnectionRequired}" `
  --output json --no-cli-pager

The API confirmed AVAILABLE, 2 ECPUs, 20 GB, mTLS enabled, and both autoscaling flags set to false. The AWS console showed the same capacity and availability:

adbs available
ADB-S is available with 2 ECPUs and 20 GB of storage.

Bring the private database connection to Windows

The database’s private IP is not directly reachable from your Windows desktop. The connection uses your EC2 client and ODB peering.

Open a new Windows PowerShell window and set the two IDs saved from your successful apply summaries. Replace the placeholders before running:

Find the EC2 and database IDs in GitHub apply outputs
Copy client_instance_id from the network apply into $instanceId, and database_id from the database apply into $databaseId.
$instanceId = "YOUR_CLIENT_INSTANCE_ID"
$databaseId = "YOUR_AUTONOMOUS_DATABASE_ID"

Use this window for the AWS checks and tunnel. If AWS reports an expired session, run aws login --profile odb-lab --region us-east-1 using the full AWS executable path shown earlier.

There were three separate security pieces:

Piece Responsibility
Session Manager plugin and tunnel Carry Windows TCP traffic through the authorized EC2 session
Database wallet Supply client credentials for mTLS
ADMIN password Authenticate the database user

The tunnel did not replace the wallet or database password.

Download the database wallet

In the AWS ODB console, select the database and open Database connections. Select Instance wallet, click Download wallet, and enter a wallet-protection password privately.

Save the downloaded ZIP as ADBSLAB01.zip on the desktop. Confirm that the archive contains tnsnames.ora and the adbslab01_low service. A wallet contains sensitive client credentials: keep the ZIP and its password out of repositories, screenshots, and public file shares.

The wallet password protects the downloaded wallet. The SQL Developer login uses the database user's ADMIN password.

Install the Windows Session Manager plugin

Remote-host forwarding requires the Windows Session Manager plugin in addition to AWS CLI v2. Install the official AWS plugin, then verify it:

& "C:\Program Files\Amazon\SessionManagerPlugin\bin\session-manager-plugin.exe" --version

The version used in this connection was 1.2.896.0. AWS documents the installer and its administrator requirement in the Windows plugin installation guide.

Start EC2 and confirm SSM is Online

Run these commands in the Windows PowerShell window where you set $instanceId and $databaseId. Use the IDs from your deployment, rather than IDs shown in screenshots.

If the EC2 client is stopped, start it:

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ec2 start-instances --instance-ids $instanceId --profile odb-lab --region us-east-1 --no-cli-pager
& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ec2 wait instance-running --instance-ids $instanceId --profile odb-lab --region us-east-1

To display the table shown in the screenshot, run:

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ssm describe-instance-information --filters "Key=InstanceIds,Values=$instanceId" --query "InstanceInformationList[].{Agent:AgentVersion,Connection:PingStatus,Platform:PlatformName}" --output table --profile odb-lab --region us-east-1 --no-cli-pager

Wait until Connection shows Online. If the table is empty or shows another status, allow the instance and SSM agent time to start, then rerun the check. Once Online, continue with the remote-host forwarding command below.

EC2 client Online in Systems Manager
Confirm that the EC2 client shows Online in Systems Manager before starting the forwarding command.

Verify EC2 can reach the listener

Before opening the Windows tunnel, check that EC2 can connect to the database on TCP port 1522. This tests the private network path from the application VPC through ODB peering to the database.

1. Find the database’s private IP — run this in Windows PowerShell.

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb get-autonomous-database `
  --autonomous-database-id $databaseId `
  --profile odb-lab --region us-east-1 `
  --query "autonomousDatabase.privateEndpointIp" --output text --no-cli-pager

The command returns the current private IP for this lab’s database. Keep that address for the next step. If using another database, replace the database ID too.

You can also find this address in the AWS console: open Oracle Database@AWS → Autonomous AI Databases Serverless → adbs-lab-01 → Connectivity → Network access → Private endpoint IP.

Database Connectivity tab private endpoint location

2. Open a shell on the EC2 client.

Ensure the client is running and Online in Systems Manager. In the AWS console, go to Systems Manager → Session Manager → Start session, select the lab EC2 client, and start the session.

ssm session blog
Session Manager opens a shell on the EC2 client. Run the next command there, rather than in Windows PowerShell.

3. Test the database port from EC2.

Replace YOUR_ADB_PRIVATE_IP with the address returned in step 1, then run:

python3 -c "import socket; s=socket.create_connection(('YOUR_ADB_PRIVATE_IP',1522),10); print('ADB mTLS listener TCP reachable from EC2'); s.close()"

A successful connection prints:

ADB mTLS listener TCP reachable from EC2

4. Confirm the successful result.

The same TCP check was executed with SSM Run Command in the verified lab. Its recorded output below shows Success, response code 0, and the listener-reachable message.

EC2 to ADB TCP listener test succeeded
Recorded successful EC2-to-database TCP check in Systems Manager.

This confirms TCP connectivity to port 1522. The SQL Developer connection later verifies the wallet, TLS, and database login.

Start remote-host forwarding

Return to Windows PowerShell, not the browser’s Linux shell. The following command reads the database’s current private IP automatically, using $databaseId and $instanceId set above. Keep local port 1522 available.

$env:PATH = "C:\Program Files\Amazon\SessionManagerPlugin\bin;" + $env:PATH

$dbIp = & "C:\Program Files\Amazon\AWSCLIV2\aws.exe" odb get-autonomous-database --autonomous-database-id $databaseId --query "autonomousDatabase.privateEndpointIp" --output text --profile odb-lab --region us-east-1 --no-cli-pager
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($dbIp) -or $dbIp.Trim() -eq "None") {
    throw "Database private IP lookup failed. Check the AWS login and database ID."
}

$parameters = @{
    host = @($dbIp.Trim())
    portNumber = @("1522")
    localPortNumber = @("1522")
} | ConvertTo-Json -Compress

$parameterFile = Join-Path $env:TEMP "adbs-tunnel-parameters.json"
[System.IO.File]::WriteAllText($parameterFile, $parameters, [System.Text.UTF8Encoding]::new($false))

& "C:\Program Files\Amazon\AWSCLIV2\aws.exe" ssm start-session --target $instanceId --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters "file://$parameterFile" --profile odb-lab --region us-east-1

The session reported Port 1522 opened and waited for connections. Keep that process running while using SQL Developer. The local plugin and EC2 agent coordinate the session; the remote host is the database, not EC2's own port 1522. AWS remote-host forwarding instructions

SSM remote-host tunnel open on local port 1522
Port 1522 is open and the SSM tunnel is waiting for SQL Developer connections. Keep this PowerShell window open.

Checkpoint: the tunnel window shows Port 1522 opened and Waiting for connections. Leave it running. Open a second Windows PowerShell window and check the local listener:

Test-NetConnection 127.0.0.1 -Port 1522

A successful local TCP test proves that a listener is present. It does not by itself prove that the wallet, service name, or password is correct.

Preserve the wallet hostname and TLS validation

Open tnsnames.ora from the wallet ZIP and find the HOST for the service you will select in SQL Developer. Use your own wallet hostname in the next command.

Preserve that hostname and the wallet’s ssl_server_dn_match=yes setting. Map it to 127.0.0.1 so SQL Developer sends traffic through the open tunnel while retaining the original hostname for TLS verification.

Use the second PowerShell window, opened as Administrator. Back up the hosts file before editing it, and add the following mapping once:

$walletHost = "YOUR_EXACT_HOSTNAME_FROM_TNSNAMES_ORA"
Add-Content -LiteralPath "$env:windir\System32\drivers\etc\hosts" -Value "`r`n127.0.0.1 $walletHost # AWS ADBS SSM tunnel"

For another database, use the exact hostname from its wallet. Add the entry once and preserve existing mappings. The local forwarding port must match the port in the chosen wallet entry.

This directs the connection through localhost without changing the hostname that the client uses for certificate verification. Keep server-DN matching enabled.

Configure SQL Developer and run a real query

In the desktop SQL Developer connection dialog, select Cloud Wallet and enter:

Field Value
Connection name ADBSLAB01
Username ADMIN
Password Database ADMIN password, entered privately
Connection type Cloud Wallet
Configuration file Desktop wallet ZIP, ADBSLAB01.zip
Service adbslab01_low
Role default

Oracle documents this connection type and wallet ZIP selection in its SQL Developer mTLS guide.

Click Test and confirm Status: Success. Then click Connect and run:

SELECT USER,
       SYS_CONTEXT('USERENV', 'DB_NAME') AS database_name
FROM dual;

The result showed ADMIN and the database's generated name ending in _ADBSLAB01.

adbs sql developer identity verified
The identity query confirms the connected user and the intended ADBSLAB01 database.

Run the version query:

SELECT banner_full FROM v$version;
adbs sql developer version verified
A successful SQL query returns the engine version through the complete desktop-to-database path.

The banner reported:

Oracle AI Database 26ai Enterprise Edition
Release 23.26.4.1.0 - Production
Version 23.26.4.1.0

There is a useful distinction here: the AWS API's dbVersion field returned 23ai, while the running database's SQL banner identified itself as Oracle AI Database 26ai, version 23.26.4.1.0. Use the SQL banner to verify the running engine's full version; retain the API label separately when documenting the deployment.

This SQL result was the final confirmation of the connection path: Windows SQL Developer, local forwarding, SSM, EC2, ODB peering, the private listener, mTLS, and database authentication.

Provider note: The repository includes a workaround for a known provider issue affecting EC2 creation and removal. Review its troubleshooting notes before modifying or destroying the ODB network.

Conclusion

This guide provisioned Oracle Autonomous Database Serverless on AWS using Terraform and GitHub Actions, then verified the database connection from Windows SQL Developer through an SSM tunnel.

The one-time bootstrap connected GitHub to AWS using OIDC and created the roles and state storage. After that setup, provisioning followed the same workflow: enter the deployment settings, generate a Terraform plan, review the changes, and apply the saved plan.

Separating networking from database deployments makes the process reusable. Additional databases can use the existing ODB network, with a unique deployment name and separate Terraform state for each database. When a separate network is needed, the network workflow can create another named stack with non-overlapping address ranges.

With the infrastructure defined in code and executed through workflows, the lab becomes a repeatable process for creating and managing database environments. Future deployments can follow the same reviewed steps without rebuilding the setup manually.

Share on LinkedIn ↗

Join the discussion

Ask a question, share a result, or add a useful tip.

Loading comments…

Leave a comment

Your name and comment will be public. Keep passwords, email addresses, IP addresses, and other private details out of your comment. Cloudflare Turnstile checks submissions to help prevent spam.