# How to create a basic EventBridge in Serverless

**URL:** <https://forum.serverless.com/t/how-to-create-a-basic-eventbridge-in-serverless/9259>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [September 9, 2019, 11:02am UTC](https://forum.serverless.com/t/how-to-create-a-basic-eventbridge-in-serverless/9259 "2019-09-09T11:02:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asisodiya](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asisodiya](https://forum.serverless.com/u/asisodiya)\
**Post date:** [September 9, 2019, 11:02am UTC](https://forum.serverless.com/t/how-to-create-a-basic-eventbridge-in-serverless/9259/1 "2019-09-09T11:02:47Z")

</div>

Hi, I am trying to create a Simple AWS EventBridge on a Lambda Function, both of which are being created using Serverless Script.

Here is the code I am trying to use in serverless.yml **(Some variables are unset)** also handler.js is default

```
service: event-bridge-cloudformation

provider:
  name: aws
  runtime: nodejs10.x
  region: us-east-1

functions:
  hello:
    handler: handler.hello

resources:
 Resources:
    ScheduledRule: 
      Type: AWS::Events::Rule
      Properties: 
        Description: "ScheduledRule"
        ScheduleExpression: "rate(1 minutes)"
        State: "ENABLED"
        Targets: 
          - 
            Arn: 
              Fn::GetAtt: 
                - "arn:aws:lambda:${self:provider.region}:${self:provider.environment.AWS_ACCOUNT}:function:${self:service}-${self:provider.stage}-hello"
                - "Arn"

```

Above code is giving me following error:  
`Error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource`

Can you please help me with some basic template in serverless that creates both lambda and an EventBridge on that Lambda

Thanks.

---

<div class="post-metadata">

**Author:** ![bfieber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bfieber/32/653_2.png) [@bfieber](https://forum.serverless.com/u/bfieber)\
**Post date:** [September 9, 2019, 3:05pm UTC](https://forum.serverless.com/t/how-to-create-a-basic-eventbridge-in-serverless/9259/2 "2019-09-09T15:05:51Z")

</div>

> [@asisodiya](#):
>
> ```auto
> Targets:
> - 
> Arn:
> Fn::GetAtt: 
> - "arn:aws:lambda:${self:provider.region}:${self:provider.environment.AWS_ACCOUNT}:function:${self:service}-${self:provider.stage}-hello"
> - "Arn"
> 
> ```

Looks like you’re trying to get an Arn from an Arn. That is, you’re constructing the arn as a string, then trying to get the arn from that string. Here’s 2 potential solutions to your issue:

1. Construct the Arn as a string:

```auto
Targets:
  - 
    Arn: "arn:aws:lambda:${self:provider.region}:${self:provider.environment.AWS_ACCOUNT}:function:${self:service}-${self:provider.stage}-hello"

```

1. Get the Arn from the LogicalId of the Hello Function

```auto
Targets:
  - 
    Arn:
        Fn::GetAtt: 
          - "HelloLambdaFunction"
          - "Arn"

```

Hope it helps.

---

<div class="post-metadata">

**Author:** ![asisodiya](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@asisodiya](https://forum.serverless.com/u/asisodiya)\
**Post date:** [September 18, 2019, 6:00am UTC](https://forum.serverless.com/t/how-to-create-a-basic-eventbridge-in-serverless/9259/3 "2019-09-18T06:00:31Z")

</div>

Thanks Brett, it helped 🙂
