Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref intrinsic for SecurityGroup #240

Open
t0yv0 opened this issue Nov 21, 2024 · 0 comments
Open

Ref intrinsic for SecurityGroup #240

t0yv0 opened this issue Nov 21, 2024 · 0 comments
Labels
kind/enhancement Improvements or new features

Comments

@t0yv0
Copy link
Member

t0yv0 commented Nov 21, 2024

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

The docs specify a complex behavior for the Ref intrinsic for this resource:

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ID of the security group if
you specified the VpcId property. Otherwise, it returns the name of the security group. If you omit the VpcId property
and need the ID of the VPC, use Fn::GetAtt instead.

This seem to bear out in practice.

AWSTemplateFormatVersion: '2010-09-09'
Description: A template to create a security group allowing SSH access.

Resources:

  # PulumiTestVPC:
  #   Type: AWS::EC2::VPC
  #   Properties:
  #     CidrBlock: 10.0.0.0/16

  PulumiTestTestSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Allow SSH access
      # VpcId:
      #   Ref: PulumiTestVPC
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 22
          ToPort: 22
          CidrIp: 0.0.0.0/0  # Allow SSH from anywhere (use cautiously)

Outputs:
  TestOutput1:
    Value: !Ref PulumiTestTestSecurityGroup

Without VpcId I get this:

AntonStack-AntonTestSecurityGroup-gDbu6UPqIWDL

With VpcId I get sg-01e8f63de351adcfb:

I think in pulumi-cdk emulation of the CF Ref behavior we can default to assuming VpcId is set and returning GroupId for Ref, but leaving this ticket open in the backlog just in case we will need to revisit the "missing VpcId" behavior for completeness.

Affected area/feature

@t0yv0 t0yv0 added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team and removed needs-triage Needs attention from the triage team labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

1 participant