-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
228 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
package cloud.cleo.chimesma.cdk; | ||
|
||
import cloud.cleo.chimesma.cdk.customresources.ChimeVoiceConnector; | ||
import cloud.cleo.chimesma.cdk.twilio.*; | ||
import software.amazon.awscdk.App; | ||
import software.constructs.Construct; | ||
import software.amazon.awscdk.Stack; | ||
import software.amazon.awscdk.StackProps; | ||
|
||
/** | ||
* CDK Stack | ||
* CDK Stack | ||
* | ||
* @author sjensen | ||
*/ | ||
public class TwilioStack extends Stack { | ||
|
||
|
||
public TwilioStack(final App parent, final String id, String vc1, String vc2) { | ||
this(parent, id, null,vc1,vc2); | ||
public TwilioStack(final App parent, final String id, ChimeVoiceConnector vc1, ChimeVoiceConnector vc2) { | ||
this(parent, id, null, vc1, vc2); | ||
} | ||
|
||
public TwilioStack(final Construct parent, final String id, final StackProps props, String vc1, String vc2) { | ||
public TwilioStack(final Construct parent, final String id, final StackProps props, ChimeVoiceConnector vc1, ChimeVoiceConnector vc2) { | ||
super(parent, id, props); | ||
|
||
new TwilioSipTrunk(this,vc1, vc2); | ||
new TwilioRule(this); | ||
|
||
// Create the Trunk | ||
final var sipTrunk = new TwilioSipTrunk(this); | ||
|
||
// Set the Orig entries to the VC's | ||
new TwilioOriginationUrl(this, sipTrunk.getSid(), vc1); | ||
new TwilioOriginationUrl(this, sipTrunk.getSid(), vc2); | ||
} | ||
|
||
} |
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
45 changes: 45 additions & 0 deletions
45
src/main/java/cloud/cleo/chimesma/cdk/twilio/TwilioOriginationUrl.java
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,45 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template | ||
*/ | ||
package cloud.cleo.chimesma.cdk.twilio; | ||
|
||
import cloud.cleo.chimesma.cdk.customresources.ChimeVoiceConnector; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import software.amazon.awscdk.CustomResource; | ||
import software.amazon.awscdk.CustomResourceProps; | ||
import software.amazon.awscdk.Stack; | ||
|
||
/** | ||
* Twilio SIP Trunk Function that will provision | ||
* | ||
* @author sjensen | ||
*/ | ||
public class TwilioOriginationUrl extends TwilioBase { | ||
|
||
private static final AtomicInteger ID_COUNTER = new AtomicInteger(0); | ||
final CustomResource cr; | ||
|
||
/** | ||
* @param scope | ||
* @param trunkSid | ||
* @param vc | ||
*/ | ||
public TwilioOriginationUrl(Stack scope, String trunkSid, ChimeVoiceConnector vc) { | ||
super(scope, TwilioOriginationUrl.class); | ||
|
||
// Add associated Custom Resource linked to this Lambda | ||
cr = new CustomResource(this, "SipOrigUrlResource"+ ID_COUNTER.incrementAndGet(), CustomResourceProps.builder() | ||
.resourceType("Custom::" + TwilioOriginationUrl.class.getSimpleName()) | ||
.properties(Map.of("trunkSid", trunkSid, "voiceConnector", vc.getOutboundName(),"region",vc.getRegion())) | ||
.serviceToken(getFunctionArn()) | ||
.build()); | ||
|
||
} | ||
|
||
@Override | ||
public String getSid() { | ||
return cr.getRef(); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
src/main/java/cloud/cleo/chimesma/cdk/twilio/TwilioRule.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.