Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions deployments/infra/lib/kwil-indexer/kwil_indexer_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ func NewIndexerInstance(scope constructs.Construct, input NewIndexerInstanceInpu
jsii.String("Allow HTTPS to the v1 API."),
jsii.Bool(false))

// testnet indexer: a second indexer, set up on the host for testnet, serves
// its API on 8080 directly.
instanceSG.AddIngressRule(
awsec2.Peer_AnyIpv4(),
awsec2.Port_Tcp(jsii.Number(8080)),
jsii.String("Allow the testnet indexer API."),
jsii.Bool(false))

// Get key-pair pointer.
keyPair := awsec2.KeyPair_FromKeyPairName(scope, jsii.String("KeyPair-ind"), jsii.String(config.KeyPairName(scope)))

Expand Down
34 changes: 20 additions & 14 deletions deployments/infra/lib/kwil-indexer/kwil_indexer_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
testhelpers "github.com/trufnetwork/node/infra/tests/testhelpers"
)

// The HTTPS rule for the v1 API belongs on the indexer's own security group,
// The ports of the services set up on the indexer host (HTTPS for the v1 API,
// 8080 for the testnet indexer) belong on the indexer's own security group,
// next to ssh, whatever the fronting.
func TestIndexerSecurityGroupAllowsHTTPS(t *testing.T) {
func TestIndexerSecurityGroupAllowsPublicPorts(t *testing.T) {
app := awscdk.NewApp(nil)
stack := awscdk.NewStack(app, jsii.String("TestStack"), &awscdk.StackProps{
Env: &awscdk.Environment{
Expand Down Expand Up @@ -51,16 +52,21 @@ func TestIndexerSecurityGroupAllowsHTTPS(t *testing.T) {
})

template := assertions.Template_FromStack(stack, nil)
template.HasResourceProperties(jsii.String("AWS::EC2::SecurityGroup"), map[string]interface{}{
"GroupDescription": "Kwil Indexer Security Group.",
"SecurityGroupIngress": assertions.Match_ArrayWith(&[]interface{}{
map[string]interface{}{
"IpProtocol": "tcp",
"FromPort": 443,
"ToPort": 443,
"CidrIp": "0.0.0.0/0",
"Description": "Allow HTTPS to the v1 API.",
},
}),
})
for port, description := range map[int]string{
443: "Allow HTTPS to the v1 API.",
8080: "Allow the testnet indexer API.",
} {
template.HasResourceProperties(jsii.String("AWS::EC2::SecurityGroup"), map[string]interface{}{
"GroupDescription": "Kwil Indexer Security Group.",
"SecurityGroupIngress": assertions.Match_ArrayWith(&[]interface{}{
map[string]interface{}{
"IpProtocol": "tcp",
"FromPort": port,
"ToPort": port,
"CidrIp": "0.0.0.0/0",
"Description": description,
},
}),
})
}
}
Loading