-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from dasmeta/DMVP-2544-api-gw-crd
DMVP-2544: Create API Gateway integration
- Loading branch information
Showing
11 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "kubernetes_manifest" "api" { | ||
for_each = { for index, api in var.api_gateway_resources : index => api } | ||
manifest = { | ||
apiVersion = "apigatewayv2.services.k8s.aws/v1alpha1" | ||
kind = "API" | ||
metadata = { | ||
name = each.value.api.name | ||
namespace = each.value.namespace | ||
} | ||
spec = { | ||
name = each.value.api.name | ||
protocolType = each.value.api.protocolType | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
resource "kubernetes_manifest" "stage" { | ||
#for_each = { for api in flatten([for api in var.api_gateway_resources : api.stages]) : api.name => api } | ||
for_each = { for stage in flatten([for api in var.api_gateway_resources : api.stages != null ? api.stages : []]) : stage.name => stage } | ||
manifest = { | ||
apiVersion = "apigatewayv2.services.k8s.aws/v1alpha1" | ||
kind = "Stage" | ||
metadata = { | ||
name = each.value.name | ||
namespace = each.value.namespace != null ? each.value.namespace : "default" | ||
} | ||
spec = { | ||
apiRef = { | ||
from = { | ||
name = each.value.apiRef_name | ||
} | ||
} | ||
stageName = each.value.stageName | ||
autoDeploy = each.value.autoDeploy | ||
description = each.value.description | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# data | ||
provider "helm" { | ||
kubernetes { | ||
config_path = "~/.kube/config" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module "basic" { | ||
source = "../.." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# basic | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_basic"></a> [basic](#module\_basic) | ../.. | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
No inputs. | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
data "aws_region" "this" {} | ||
|
||
data "aws_subnet" "selected" { | ||
count = var.api_gateway_resources[0].vpc_links != null ? length(local.subnet_ids) : 0 | ||
id = local.subnet_ids[count.index] | ||
} | ||
|
||
resource "kubernetes_manifest" "vpc_link" { | ||
#for_each = { for link in flatten([for api in var.api_gateway_resources : api.vpc_links]) : link.name => link } | ||
for_each = { for link in flatten([for api in var.api_gateway_resources : api.vpc_links != null ? api.vpc_links : []]) : link.name => link } | ||
manifest = { | ||
apiVersion = "apigatewayv2.services.k8s.aws/v1alpha1" | ||
kind = "VPCLink" | ||
metadata = { | ||
name = each.value.name | ||
namespace = each.value.namespace != null ? each.value.namespace : "default" | ||
} | ||
spec = { | ||
name = each.value.name | ||
securityGroupIDs = [aws_security_group.api-gw-sg[0].id] | ||
subnetIDs = var.subnet_ids | ||
} | ||
} | ||
} | ||
|
||
resource "aws_security_group" "api-gw-sg" { | ||
count = var.api_gateway_resources[0].vpc_links != null ? 1 : 0 | ||
vpc_id = var.vpc_id | ||
name = "aws-api-gw-${var.cluster_name}-${data.aws_region.this.name}-sg" | ||
description = "Allow traffic from EKS to API gateway" | ||
|
||
ingress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = local.cidrs | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
locals { | ||
subnet_ids = var.subnet_ids | ||
cidrs = [for s in data.aws_subnet.selected : s.cidr_block] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters