title: aws lambda - How to add s3 trigger using cloudformation if the s3 bucket is created manually
body: <p>I have created my s3 bucket &quot;myBucket&quot; manually.<br></p>
  <p>And I need a lambda function with s3 trigger.<br></p>
  <pre><code>    &quot;Parameters&quot;: {
        &quot;HandlerCodeS3Bucket&quot;: {
          &quot;Type&quot;: &quot;String&quot;,
          &quot;Default&quot;: &quot;myBucket&quot;
        },
      },
      &quot;Resources&quot;: {
        &quot;uploadBannerToS3Handler&quot;: {
          &quot;Type&quot;: &quot;AWS::Lambda::Function&quot;,
          &quot;Properties&quot;: {
            &quot;FunctionName&quot;: &quot;uploadBannerToS3&quot;,
            &quot;Handler&quot;: &quot;uploadBannerToS3.handler&quot;,
            &quot;Role&quot;: {
              &quot;Fn::ImportValue&quot;: {
                &quot;Fn::Sub&quot;: &quot;${RolesStack}-LambdaRoleArn&quot;
              }
            },
            &quot;Code&quot;: {
              &quot;S3Bucket&quot;: {
                &quot;Ref&quot;: &quot;HandlerCodeS3Bucket&quot;
              },
              &quot;S3Key&quot;:&quot;uploadBannerToS3.zip&quot;
            },
            &quot;Layers&quot;: [
              {
                &quot;Ref&quot;: &quot;MyLayer&quot;
              }
            ],
            &quot;Runtime&quot;: &quot;nodejs12.x&quot;
          }
        }
            ...
      }
  </code></pre>
  <p>How should I modify the code to add s3 trigger in my function.<br></p>
  <p>Also, for development, is it more convenient if I build my s3 bucket in cloudformation also, if I will build my UAT environment in the future?<br>
  How would developer normally do for s3 if using cloudformation?</p>