Coder Social home page Coder Social logo

feature: sst.aws.Bus about ion HOT 12 OPEN

thdxr avatar thdxr commented on August 18, 2024 17
feature: sst.aws.Bus

from ion.

Comments (12)

jamlen avatar jamlen commented on August 18, 2024 2

This is a definite blocker for us moving to v3 as we use EventBridge extensively to decouple.

from ion.

eduardokanema avatar eduardokanema commented on August 18, 2024

Hi @thdxr, I'm happy to do the implementation of this component. Any specifications that I should follow?

from ion.

kieranm avatar kieranm commented on August 18, 2024

Bus is available, it's just undocumented at the moment:
https://github.com/sst/ion/tree/dev/examples/aws-bus

from ion.

joshsutheran-habitude avatar joshsutheran-habitude commented on August 18, 2024

Agreed with @jamlen - leverage EventBridge heavily to decouple - would be great to prioritise this.

from ion.

kieranm avatar kieranm commented on August 18, 2024

@joshsutheran-habitude It has been implemented already - see the link I posted above

from ion.

ajotaos avatar ajotaos commented on August 18, 2024

What approach there is for referencing the default bus using this component? I tried to follow the import option but it said that it would not let me assign "default" as a name.

from ion.

eduardokanema avatar eduardokanema commented on August 18, 2024

What approach there is for referencing the default bus using this component? I tried to follow the import option but it said that it would not let me assign "default" as a name.

Hi @ajotaos, maybe because the resources need to start with Capital letters? Try Default

from ion.

ajotaos avatar ajotaos commented on August 18, 2024

No luck sorry, if I do that:

new sst.aws.Bus(prefixComponentName('Default'), {
	transform: {
		bus: (args, opts) => {
			args.name = 'Default' // or even if I omit this line

			opts.import = 'default'
		}
	}
})

The CLI rejects it with:

✕  Failed
   ComicbookPagesDefault sst:aws:Bus → ComicbookPagesDefaultBus aws:cloudwatch:EventBus
   inputs to import do not match the existing resource

Set the following in your transform:
   - `args.name = "default";`

Otherwise if I do this instead:

new sst.aws.Bus(prefixComponentName('Default'), {
	transform: {
		bus: (args, opts) => {
			args.name = 'default'

			opts.import = 'default'
		}
	}
})

The CLI rejects it with:

✕  Failed
   ComicbookPagesDefault sst:aws:Bus → ComicbookPagesDefaultBus aws:cloudwatch:EventBus
   aws:cloudwatch/eventBus:EventBus resource 'ComicbookPagesDefaultBus' has a problem: invalid value for name (cannot be 'default'). Examine values at 'ComicbookPagesDefaultBus.name'.

from ion.

wedgybo avatar wedgybo commented on August 18, 2024

As this feature isn't fully finished I thought I'd raise a simple issue here when importing partner buses. Because of the long name given to the bus when it's a partner one it breaks the character limit when trying to create the rule and target.

export const shopify = new sst.aws.Bus('Shopify', {
    transform: {
        bus: (args, opts) => {
            args.name = 'aws.partner/shopify.com/XXXXXXXXXX/together-dev-jsutherland'
            // opts.import = 'aws.partner/shopify.com/XXXXXXXXX/together-dev-jsutherland'
        }
    }
})
Failed AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzRule aws:cloudwatch:EventRule could not make instance of 'aws:cloudwatch/eventRule:EventRule': name 'AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzRule-' plus 7 random chars is longer than maximum length 64
Failed AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzTarget aws:cloudwatch:EventTarget aws:cloudwatch/eventTarget:EventTarget resource 'AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzTarget' has a problem: "target_id" cannot be longer than 64 characters: "AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzTarget-e1e5c79". Examine values at 'AwspartnershopifycomXXXXXXXXXXtogetherdevjsutherlandSubscriberHrtotzTarget.targetId'.

This is the workaround below incase anyone else is running into the same issues

// We overwrite the generated rule names when subscribing
// as they are too long when importing a partner event bus.
events.shopify.subscribe('services/upload/src/events.shopify', {
  transform: {
    rule: (args, opts) => {
      args.name = 'new_rule_name'
    },
    target: (args, opts) => {
      args.targetId = 'new_target_id'
    }
  }
})

from ion.

exceptionrambler avatar exceptionrambler commented on August 18, 2024

@joshsutheran-habitude It has been implemented already - see the link I posted above

We are relatively new to SST but use EventBus heavily in v2.
Do you happen to have an example implementation of EventBus in Ion?
We think it makes sense for us to migrate but are hesitant to do so without this being documented.

from ion.

ajotaos avatar ajotaos commented on August 18, 2024

I ended up using the static function of Bus.subscribe and getting the ARN from the pulumi aws module function.

from ion.

mckamyk avatar mckamyk commented on August 18, 2024

@joshsutheran-habitude It has been implemented already - see the link I posted above

We are relatively new to SST but use EventBus heavily in v2. Do you happen to have an example implementation of EventBus in Ion? We think it makes sense for us to migrate but are hesitant to do so without this being documented.

sst.config.ts
https://github.com/sst/ion/blob/3cc1603bba6a1eb8a4a178134450f808fb253ddb/examples/aws-bus/sst.config.ts

publisher
https://github.com/sst/ion/blob/3cc1603bba6a1eb8a4a178134450f808fb253ddb/examples/aws-bus/src/index.ts

subscriber
https://github.com/sst/ion/blob/3cc1603bba6a1eb8a4a178134450f808fb253ddb/examples/aws-bus/src/receiver.ts

I'd recommend adding filters if you have more than one subscriber.
mentioned in #533

from ion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.