Skip to content

Commit

Permalink
Add table aws_app_runner_service Closes #2248
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI committed Aug 21, 2024
1 parent 66c95e1 commit 1ec0808
Show file tree
Hide file tree
Showing 15 changed files with 531 additions and 0 deletions.
Empty file.
7 changes: 7 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"arn": "{{ output.resource_aka.value}}",
"service_id": "{{ output.resource_id.value}}",
"service_name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select arn, service_name, service_id
from aws_app_runner_service
where arn = '{{ output.resource_aka.value }}'
7 changes: 7 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"arn": "{{ output.resource_aka.value}}",
"service_id": "{{ output.resource_id.value}}",
"service_name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select arn, service_name, service_id
from aws_app_runner_service
where akas::text = '["{{ output.resource_aka.value }}"]'
10 changes: 10 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-turbot-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account_id": "{{output.account_id.value}}",
"akas": [
"{{ output.resource_aka.value }}"
],
"region": "{{output.aws_region.value}}",
"title": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_app_runner_service/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select title, akas, region, account_id
from aws_app_runner_service
where arn = '{{ output.resource_aka.value }}'
1 change: 1 addition & 0 deletions aws-test/tests/aws_app_runner_service/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
87 changes: 87 additions & 0 deletions aws-test/tests/aws_app_runner_service/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

variable "resource_name" {
type = string
default = "turbot-test-20200125-create-update"
description = "Name of the resource used throughout the test."
}

variable "aws_profile" {
type = string
default = "default"
description = "AWS credentials profile used for the test. Default is to use the default profile."
}

variable "aws_region" {
type = string
default = "us-east-1"
description = "AWS region used for the test. Does not work with default region in config, so must be defined here."
}

variable "aws_region_alternate" {
type = string
default = "us-east-2"
description = "Alternate AWS region used for tests that require two regions (e.g. DynamoDB global tables)."
}

provider "aws" {
profile = var.aws_profile
region = var.aws_region
}

provider "aws" {
alias = "alternate"
profile = var.aws_profile
region = var.aws_region_alternate
}

data "aws_partition" "current" {}
data "aws_caller_identity" "current" {}
data "aws_region" "primary" {}
data "aws_region" "alternate" {
provider = aws.alternate
}

data "null_data_source" "resource" {
inputs = {
scope = "arn:${data.aws_partition.current.partition}:::${data.aws_caller_identity.current.account_id}"
}
}

resource "aws_apprunner_service" "named_test_resource" {
service_name = var.resource_name

source_configuration {
image_repository {
image_configuration {
port = "8000"
}
image_identifier = "public.ecr.aws/aws-containers/hello-app-runner:latest"
image_repository_type = "ECR_PUBLIC"
}
auto_deployments_enabled = false
}

tags = {
Name = var.resource_name
}
}

output "resource_aka" {
value = aws_apprunner_service.named_test_resource.arn
}

output "resource_id" {
value = aws_apprunner_service.named_test_resource.service_id
}

output "account_id" {
value = data.aws_caller_identity.current.account_id
}

output "aws_region" {
value = data.aws_region.primary.name
}

output "resource_name" {
value = var.resource_name
}
1 change: 1 addition & 0 deletions aws/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"aws_api_gatewayv2_integration": tableAwsAPIGatewayV2Integration(ctx),
"aws_api_gatewayv2_route": tableAwsAPIGatewayV2Route(ctx),
"aws_api_gatewayv2_stage": tableAwsAPIGatewayV2Stage(ctx),
"aws_app_runner_service": tableAwsAppRunnerService(ctx),
"aws_appautoscaling_policy": tableAwsAppAutoScalingPolicy(ctx),
"aws_appautoscaling_target": tableAwsAppAutoScalingTarget(ctx),
"aws_appconfig_application": tableAwsAppConfigApplication(ctx),
Expand Down
13 changes: 13 additions & 0 deletions aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/apigatewayv2"
"github.com/aws/aws-sdk-go-v2/service/appconfig"
"github.com/aws/aws-sdk-go-v2/service/applicationautoscaling"
"github.com/aws/aws-sdk-go-v2/service/apprunner"
"github.com/aws/aws-sdk-go-v2/service/appstream"
"github.com/aws/aws-sdk-go-v2/service/appsync"
"github.com/aws/aws-sdk-go-v2/service/athena"
Expand Down Expand Up @@ -149,6 +150,7 @@ import (

amplifyEndpoint "github.com/aws/aws-sdk-go/service/amplify"
apigatewayv2Endpoint "github.com/aws/aws-sdk-go/service/apigatewayv2"
appRunnerEndpoint "github.com/aws/aws-sdk-go/service/apprunner"
appsyncv2Endpoint "github.com/aws/aws-sdk-go/service/appsync"
auditmanagerEndpoint "github.com/aws/aws-sdk-go/service/auditmanager"
backupEndpoint "github.com/aws/aws-sdk-go/service/backup"
Expand Down Expand Up @@ -313,6 +315,17 @@ func ApplicationAutoScalingClient(ctx context.Context, d *plugin.QueryData) (*ap
return applicationautoscaling.NewFromConfig(*cfg), nil
}

func AppRunnerClient(ctx context.Context, d *plugin.QueryData) (*apprunner.Client, error) {
cfg, err := getClientForQuerySupportedRegion(ctx, d, appRunnerEndpoint.EndpointsID)
if err != nil {
return nil, err
}
if cfg == nil {
return nil, nil
}
return apprunner.NewFromConfig(*cfg), nil
}

func AppStreamClient(ctx context.Context, d *plugin.QueryData) (*appstream.Client, error) {
cfg, err := getClientForQueryRegion(ctx, d)
if err != nil {
Expand Down
Loading

0 comments on commit 1ec0808

Please sign in to comment.