Last active
May 2, 2025 19:54
-
-
Save filipeandre/687118ee0c5c52f37cfd4c61e38cd914 to your computer and use it in GitHub Desktop.
Test substitution logic for IP construction with dummy resource (sub, select, ssm)
This file contains hidden or 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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Test substitution logic for IP construction with dummy resource. | |
Resources: | |
DummyResource: | |
Type: AWS::CloudFormation::WaitConditionHandle | |
Outputs: | |
FabricComponentsStaticIP: | |
Value: !Sub | |
- "${Octet1}.${Octet2}.${Octet3}.10/${SubnetMask}" | |
- Octet1: !Select [0, !Split [".", "10.1.2.0"]] | |
Octet2: !Select [1, !Split [".", "10.1.2.0"]] | |
Octet3: !Select [2, !Split [".", "10.1.2.0"]] | |
SubnetMask: "{{resolve:ssm:/subnet_mask}}" |
This file contains hidden or 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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Test substitution logic for IP construction with dummy resource. | |
Resources: | |
DummyResource: | |
Type: AWS::CloudFormation::WaitConditionHandle | |
CouchDBInstanceStaticIPAZ1Config: | |
Type: Custom::JsCode | |
Properties: | |
ServiceToken: !Sub '{{resolve:ssm:/JsVmArn}}' | |
JSCode: !Sub | | |
( () => { | |
const cidr = "{{resolve:ssm:/Subnet1Cidr}}"; | |
const subnetMask = "{{resolve:ssm:/subnet_mask}}"; | |
const [octet1, octet2, octet3] = cidr.split("/")[0].split("."); | |
const staticIP = `${!octet1}.${!octet2}.${!octet3}.10/${!subnetMask}`; | |
return { | |
StaticIP: staticIP | |
}; | |
})() | |
Outputs: | |
StaticIP: | |
Value: !GetAtt CouchDBInstanceStaticIPAZ1Config.StaticIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment