@@ -26,10 +26,11 @@ type Configuration struct {
2626
2727// IntegrationMetadata holds resources created during integration setup.
2828type IntegrationMetadata struct {
29- TopicID string `json:"topicId" mapstructure:"topicId"`
30- // CompartmentRules maps compartment OCID → Events rule OCID.
31- // One shared rule is created per compartment, reused across all triggers.
32- CompartmentRules map [string ]string `json:"compartmentRules" mapstructure:"compartmentRules"`
29+ TopicID string `json:"topicId" mapstructure:"topicId"`
30+ EventsRuleID string `json:"eventsRuleId" mapstructure:"eventsRuleId"`
31+ // Deprecated: CompartmentRules was used in older versions to track per-compartment rules.
32+ // It is kept only for cleanup of legacy resources.
33+ CompartmentRules map [string ]string `json:"compartmentRules,omitempty" mapstructure:"compartmentRules"`
3334}
3435
3536func (o * OCI ) Name () string {
@@ -56,45 +57,54 @@ SuperPlane authenticates to OCI using API Key authentication tied to a dedicated
5657### Part 1 — Create a Dedicated Group and Service User
5758
58591. Open the [OCI Console](https://cloud.oracle.com/) and sign in.
59- 2. Go to **Identity & Security → Domains → Default → Groups**.
60+ 2. Go to **Menu** → ** Identity & Security → Domains → Default → User Management → Groups**.
60613. Click **Create Group**.
61624. Set the name to ` + "`SuperPlaneIntegration`" + ` and add a description, then click **Create**.
62- 5. In the same Domain , go to **Users → Create User**.
63+ 5. In the same **User Management** tab , go to **Users → Create User**.
63646. Fill in the details:
64- - **Username:** ` + "`superplane-integration`" + `
65- - **Email:** use integrations@superplane.com or any valid email (not used for authentication)
66- - **Description:** SuperPlane integration user
67- 7. In the **Groups** section, assign them to the ` + "`SuperPlaneIntegration`" + ` group
65+ - **Lastname:** ` + "`superplane-integration`" + `
66+ - **Email:** use any valid email (not used for authentication)
67+ 7. In the **Groups** section, assign the user to the ` + "`SuperPlaneIntegration`" + ` group
68688. Click **Create**.
6969
7070### Part 2 — Create an IAM Policy
7171
72721. Go to **Identity & Security → Policies**.
73732. Make sure you are in the **root compartment** (check the Compartment selector on the left).
74- 3. Click **Create Policy**, name it ` + "`SuperPlanePolicies`" + `, and enable the **manual editor**.
75- 4. Paste in the following statements, replacing ` + "`<your-compartment>`" + ` with your target compartment name and Click **Create**.:
74+ 3. Click **Create Policy**, name it ` + "`SuperPlanePolicies`" + `, add a description and enable the **manual editor**.
75+ 4. Paste in the following statements, replacing ` + "`<your-compartment>`" + ` with your target compartment name, and then Click **Create**.:
7676` + "```" + `
77- Allow group SuperPlaneIntegration to manage instances
78- in compartment <your-compartment>
79-
80- Allow group SuperPlaneIntegration to manage compute-images
81- in compartment <your-compartment>
82-
83- Allow group SuperPlaneIntegration to use virtual-network-family
84- in compartment <your-compartment>
77+ Allow group SuperPlaneIntegration to manage instances in tenancy
78+ Allow group SuperPlaneIntegration to manage volumes in tenancy
79+ Allow group SuperPlaneIntegration to manage volume-attachments in tenancy
80+ Allow group SuperPlaneIntegration to manage virtual-network-family in tenancy
81+ Allow group SuperPlaneIntegration to manage buckets in tenancy
82+ Allow group SuperPlaneIntegration to manage objects in tenancy
83+ Allow group SuperPlaneIntegration to manage objectstorage-namespaces in tenancy
84+ Allow group SuperPlaneIntegration to manage fn-app in tenancy
85+ Allow group SuperPlaneIntegration to manage fn-function in tenancy
86+ Allow group SuperPlaneIntegration to manage fn-invocation in tenancy
87+ Allow group SuperPlaneIntegration to manage ons-topics in tenancy
88+ Allow group SuperPlaneIntegration to manage ons-subscriptions in tenancy
89+ Allow group SuperPlaneIntegration to inspect compartments in tenancy
90+ Allow group SuperPlaneIntegration to inspect all-resources in tenancy
91+ Allow group SuperPlaneIntegration to manage cloudevents-rules in tenancy
92+ Allow group SuperPlaneIntegration to manage autonomous-database-family in tenancy
93+ Allow service cloudEvents to use ons-topics in tenancy
8594` + "```" + `
8695
87- ### Part 3 — Generate API Keys for the Service User and Connect to Superplane
96+ ### Part 3 — Generate API Keys for the Service User and Connect to SuperPlane
8897
89- 1. While still on the service user's page, go to **API keys → Add API key**.
90- 2. Choose **Generate API Key Pair**, download the private key, and click **Add**.
91- 3. Copy the **Configuration File Preview** values that appear to the UI:
98+ 1. Go to **Menu** → **Identity & Security → Domains → Default → User Management → Users**.
99+ 2. Choose the service user you created, then go to **API Keys → Add API Key**.
100+ 3. Select **Generate API key pair**, download the private key file and then click **Add**.
101+ 4. Copy the **Configuration File Preview** values that appear to the UI:
92102 - **User OCID** (begins with ` + "`ocid1.user.`" + `)
93103 - **Fingerprint** (e.g. ` + "`12:34:56:…`" + `)
94104 - **Tenancy OCID** (begins with ` + "`ocid1.tenancy.`" + `)
95- 4 . Select the **Region** that matches your OCI tenancy's home region.
96- 5 . Open the downloaded private key file and paste its full contents into the **Private Key** field.
97- 6 . Click **Connect** to validate the credentials and save the integration.`
105+ 5 . Select the **Region** that matches your OCI tenancy's home region.
106+ 6 . Open the downloaded private key file and paste its full contents into the **Private Key** field.
107+ 7 . Click **Connect** to validate the credentials and save the integration.`
98108}
99109
100110func (o * OCI ) Configuration () []configuration.Field {
@@ -196,6 +206,21 @@ func (o *OCI) Sync(ctx core.SyncContext) error {
196206 ctx .Integration .SetMetadata (metadata )
197207 }
198208
209+ // Create a single shared Events rule in the tenancy compartment, co-located with the topic.
210+ // The rule captures all compute launch events tenancy-wide; per-compartment filtering is
211+ // done server-side in the webhook handler. Creating the rule here (in the tenancy compartment)
212+ // avoids cross-compartment IAM issues that arise when the rule and topic are in different compartments.
213+ if metadata .EventsRuleID == "" {
214+ ruleName := fmt .Sprintf ("superplane-%s" , ctx .Integration .ID ())
215+ condition := `{"eventType": ["com.oraclecloud.computeapi.launchinstance.end"]}`
216+ rule , err := client .CreateEventsRule (cfg .TenancyOCID , ruleName , condition , metadata .TopicID )
217+ if err != nil {
218+ return fmt .Errorf ("failed to create Events rule: %w" , err )
219+ }
220+ metadata .EventsRuleID = rule .ID
221+ ctx .Integration .SetMetadata (metadata )
222+ }
223+
199224 ctx .Integration .Ready ()
200225 return nil
201226}
@@ -207,7 +232,7 @@ func (o *OCI) Cleanup(ctx core.IntegrationCleanupContext) error {
207232 return nil
208233 }
209234
210- if metadata .TopicID == "" && len (metadata .CompartmentRules ) == 0 {
235+ if metadata .TopicID == "" && metadata . EventsRuleID == "" && len (metadata .CompartmentRules ) == 0 {
211236 return nil
212237 }
213238
@@ -216,9 +241,17 @@ func (o *OCI) Cleanup(ctx core.IntegrationCleanupContext) error {
216241 return fmt .Errorf ("failed to create OCI client during cleanup: %w" , err )
217242 }
218243
244+ // Delete the single shared Events rule (current style).
245+ if metadata .EventsRuleID != "" {
246+ if err := client .DeleteEventsRule (metadata .EventsRuleID ); err != nil {
247+ ctx .Logger .Warnf ("failed to delete Events rule %q during cleanup: %v" , metadata .EventsRuleID , err )
248+ }
249+ }
250+
251+ // Delete any legacy per-compartment rules created by older versions.
219252 for compartmentID , ruleID := range metadata .CompartmentRules {
220253 if err := client .DeleteEventsRule (ruleID ); err != nil {
221- ctx .Logger .Warnf ("failed to delete Events rule %q (compartment %q) during cleanup: %v" , ruleID , compartmentID , err )
254+ ctx .Logger .Warnf ("failed to delete legacy Events rule %q (compartment %q) during cleanup: %v" , ruleID , compartmentID , err )
222255 }
223256 }
224257
0 commit comments