https://pulumi.com logo
#typescript
Title
# typescript
b

busy-magazine-48939

12/13/2019, 4:29 AM
Hello, I’ve EIP that is associated privateIp address of the instance, how do I add EIP into inbound rules of the security group attached to that instance, chicken and egg problem? I’m getting:
TypeError: Cannot read property 'publicIp' of undefined
Copy code
const sgc = new aws.ec2.SecurityGroup('sg-c', {
  vpcId: vpcId,
  name: `${baseTags.Prefix}-intranet-sg`,
  ingress: [{
    protocol: 'tcp',
    fromPort: 1521,
    toPort: 1521,
    cidrBlocks: [`${vmaEip.publicIp}/32`],
  }],
  tags: baseTags
})
Copy code
const vma = new aws.ec2.Instance('vm-a', {
  tags: { Name: `${baseTags.Prefix}-vm-a`, ...baseTags },
  instanceType: 't3.xlarge',
  vpcSecurityGroupIds: [sgc.id],
  ami: AMI_ID,
  subnetId: subnetId,
  keyName: deployer.keyName,
  privateIp: VMA_IP
}, { deleteBeforeReplace: true })
Copy code
const vmaEip = new aws.ec2.Eip("vm-a-eip", {
  associateWithPrivateIp: vma.privateIp,
  instance: vma.id,
  vpc: true,
  tags: baseTags
})
w

white-balloon-205

12/13/2019, 5:30 AM
b

busy-magazine-48939

12/13/2019, 7:29 AM
Thanks @white-balloon-205, I tried to use both
concat
and
interpolate
but it doesn’t make any effect, still getting same error
Although, I noticed that
interpolate
works within module where EIP resource is defined, but if I try to interpolate it in another module referenced via import {} then it fails
The only way I could make it work is to use
concat(stack.getOutput('outputId'))
, however my understanding always was that
getOutput()
is meant to be used for cross-stack references primarily, is my understanding wrong? Is it feasible to use
stack.getOutput()
within one stack?